bump product version to 4.1.6.2
[LibreOffice.git] / qadevOOo / runner / share / DescGetter.java
blob739e52fb67f0bd100b5a7a09a37c008577fc9e0a
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;
22 import java.util.ArrayList;
23 import java.util.StringTokenizer;
25 /**
27 * Base Interface to get a description for a given TestJob
30 public abstract class DescGetter
33 public abstract DescEntry[] getDescriptionFor(String entry,
34 String DescPath,
35 boolean debug);
37 protected abstract DescEntry getDescriptionForSingleJob(String job,
38 String descPath,
39 boolean debug);
41 protected abstract String[] createScenario(String descPath, String job,
42 boolean debug);
44 protected DescEntry[] getScenario(String url, String descPath,
45 boolean debug)
47 ArrayList<DescEntry> entryList = new ArrayList<DescEntry>();
48 String line = "";
49 BufferedReader scenario = null;
50 DescEntry[] entries = null;
52 try
54 scenario = new BufferedReader(new FileReader(url));
56 catch (java.io.FileNotFoundException fnfe)
58 System.out.println("Couldn't find file " + url);
60 return entries;
63 while (line != null)
65 try
67 if (line.startsWith("-o"))
69 String job = line.substring(3, line.length()).trim();
70 DescEntry aEntry;
71 // special in case several Interfaces are given comma separated
72 if (job.indexOf(",") < 0)
74 aEntry = getDescriptionForSingleJob(job, descPath,
75 debug);
77 else
79 ArrayList<String> subs = getSubInterfaces(job);
80 String partjob = job.substring(0, job.indexOf(",")).trim();
81 aEntry = getDescriptionForSingleJob(partjob, descPath,
82 debug);
84 if (aEntry != null)
86 for (int i = 0; i < aEntry.SubEntryCount; i++)
88 String subEntry = aEntry.SubEntries[i].longName;
89 int cpLength = aEntry.longName.length();
90 subEntry = subEntry.substring(cpLength + 2,
91 subEntry.length());
93 if (subs.contains(subEntry))
95 aEntry.SubEntries[i].isToTest = true;
100 // DescEntry aEntry = getDescriptionForSingleJob(
101 // line.substring(3).trim(), descPath,
102 // debug);
103 if (aEntry != null)
105 entryList.add(aEntry);
108 else if (line.startsWith("-sce"))
110 DescEntry[] subs = getScenario(line.substring(5,
111 line.length()).trim(), descPath,
112 debug);
114 for (int i = 0; i < subs.length; i++)
116 entryList.add(subs[i]);
119 else if (line.startsWith("-p"))
121 String[] perModule = createScenario(descPath,
122 line.substring(3).trim(), debug);
124 for (int i = 0; i < perModule.length; i++)
126 DescEntry aEntry = getDescriptionForSingleJob(
127 perModule[i].substring(3).trim(),
128 descPath, debug);
129 if (aEntry != null)
131 entryList.add(aEntry);
136 line = scenario.readLine();
138 catch (java.io.IOException ioe)
140 if (debug)
142 System.out.println("Exception while reading scenario");
149 scenario.close();
151 catch (java.io.IOException ioe)
153 if (debug)
155 System.out.println("Exception while closeing scenario");
159 if (entryList.size() == 0)
161 return null;
163 entries = new DescEntry[entryList.size()];
164 entries = entryList.toArray(entries);
166 return entries;
169 protected ArrayList<String> getSubInterfaces(String job)
171 ArrayList<String> namesList = new ArrayList<String>();
172 StringTokenizer st = new StringTokenizer(job, ",");
174 for (; st.hasMoreTokens();)
176 String token = st.nextToken();
178 if (token.indexOf(".") < 0)
180 namesList.add(token);
184 return namesList;