merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / runner / share / DescGetter.java
bloba6b7229cb7d23adba512fa3cace267d31fdd4a82
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: DescGetter.java,v $
10 * $Revision: 1.9 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 package share;
32 import java.io.BufferedReader;
33 import java.io.FileReader;
34 import java.util.ArrayList;
35 import java.util.StringTokenizer;
37 import java.util.Vector;
39 /**
41 * Base Interface to get a description for a given TestJob
44 public abstract class DescGetter
47 public abstract DescEntry[] getDescriptionFor(String entry,
48 String DescPath,
49 boolean debug);
51 protected abstract DescEntry getDescriptionForSingleJob(String job,
52 String descPath,
53 boolean debug);
55 protected abstract String[] createScenario(String descPath, String job,
56 boolean debug);
58 protected DescEntry[] getScenario(String url, String descPath,
59 boolean debug)
61 Vector entryList = new Vector();
62 String line = "";
63 BufferedReader scenario = null;
64 DescEntry[] entries = null;
66 try
68 scenario = new BufferedReader(new FileReader(url));
70 catch (java.io.FileNotFoundException fnfe)
72 System.out.println("Couldn't find file " + url);
74 return entries;
77 while (line != null)
79 try
81 if (line.startsWith("-o"))
83 String job = line.substring(3, line.length()).trim();
84 DescEntry aEntry;
85 // special in case several Interfaces are given comma separated
86 if (job.indexOf(",") < 0)
88 aEntry = getDescriptionForSingleJob(job, descPath,
89 debug);
91 else
93 ArrayList subs = getSubInterfaces(job);
94 String partjob = job.substring(0, job.indexOf(",")).trim();
95 aEntry = getDescriptionForSingleJob(partjob, descPath,
96 debug);
98 if (aEntry != null)
100 for (int i = 0; i < aEntry.SubEntryCount; i++)
102 String subEntry = aEntry.SubEntries[i].longName;
103 int cpLength = aEntry.longName.length();
104 subEntry = subEntry.substring(cpLength + 2,
105 subEntry.length());
107 if (subs.contains(subEntry))
109 aEntry.SubEntries[i].isToTest = true;
114 // DescEntry aEntry = getDescriptionForSingleJob(
115 // line.substring(3).trim(), descPath,
116 // debug);
117 if (aEntry != null)
119 entryList.add(aEntry);
122 else if (line.startsWith("-sce"))
124 DescEntry[] subs = getScenario(line.substring(5,
125 line.length()).trim(), descPath,
126 debug);
128 for (int i = 0; i < subs.length; i++)
130 entryList.add(subs[i]);
133 else if (line.startsWith("-p"))
135 String[] perModule = createScenario(descPath,
136 line.substring(3).trim(), debug);
138 for (int i = 0; i < perModule.length; i++)
140 DescEntry aEntry = getDescriptionForSingleJob(
141 perModule[i].substring(3).trim(),
142 descPath, debug);
143 if (aEntry != null)
145 entryList.add(aEntry);
150 line = scenario.readLine();
152 catch (java.io.IOException ioe)
154 if (debug)
156 System.out.println("Exception while reading scenario");
163 scenario.close();
165 catch (java.io.IOException ioe)
167 if (debug)
169 System.out.println("Exception while closeing scenario");
173 if (entryList.size() == 0)
175 return null;
177 entries = new DescEntry[entryList.size()];
178 entries = (DescEntry[]) entryList.toArray(entries);
180 return entries;
183 protected ArrayList getSubInterfaces(String job)
185 ArrayList namesList = new ArrayList();
186 StringTokenizer st = new StringTokenizer(job, ",");
188 for (int i = 0; st.hasMoreTokens(); i++)
190 String token = st.nextToken();
192 if (token.indexOf(".") < 0)
194 namesList.add(token);
198 return namesList;