2003-01-27 15:27:53 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 06:29:37 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2003-01-27 15:27:53 +00:00
|
|
|
*
|
2008-04-10 06:29:37 +00:00
|
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
2003-01-27 15:27:53 +00:00
|
|
|
*
|
2008-04-10 06:29:37 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2003-01-27 15:27:53 +00:00
|
|
|
*
|
2008-04-10 06:29:37 +00:00
|
|
|
* $RCSfile: DescGetter.java,v $
|
|
|
|
* $Revision: 1.9 $
|
2003-01-27 15:27:53 +00:00
|
|
|
*
|
2008-04-10 06:29:37 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2003-01-27 15:27:53 +00:00
|
|
|
*
|
2008-04-10 06:29:37 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2003-01-27 15:27:53 +00:00
|
|
|
*
|
2008-04-10 06:29:37 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2003-01-27 15:27:53 +00:00
|
|
|
*
|
2008-04-10 06:29:37 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2003-01-27 15:27:53 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
package share;
|
|
|
|
|
2003-05-27 11:04:04 +00:00
|
|
|
import java.io.BufferedReader;
|
|
|
|
import java.io.FileReader;
|
2005-06-14 14:42:54 +00:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.StringTokenizer;
|
2003-05-27 11:04:04 +00:00
|
|
|
|
2004-05-03 07:48:30 +00:00
|
|
|
import java.util.Vector;
|
|
|
|
|
2003-01-27 15:27:53 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Base Interface to get a description for a given TestJob
|
|
|
|
*
|
|
|
|
*/
|
2009-07-06 10:30:52 +00:00
|
|
|
public abstract class DescGetter
|
|
|
|
{
|
|
|
|
|
2003-05-27 11:04:04 +00:00
|
|
|
public abstract DescEntry[] getDescriptionFor(String entry,
|
2009-07-06 10:30:52 +00:00
|
|
|
String DescPath,
|
|
|
|
boolean debug);
|
2004-05-03 07:48:30 +00:00
|
|
|
|
|
|
|
protected abstract DescEntry getDescriptionForSingleJob(String job,
|
2009-07-06 10:30:52 +00:00
|
|
|
String descPath,
|
|
|
|
boolean debug);
|
2003-05-27 11:04:04 +00:00
|
|
|
|
2004-05-03 07:48:30 +00:00
|
|
|
protected abstract String[] createScenario(String descPath, String job,
|
2009-07-06 10:30:52 +00:00
|
|
|
boolean debug);
|
2003-05-27 11:04:04 +00:00
|
|
|
|
|
|
|
protected DescEntry[] getScenario(String url, String descPath,
|
2009-07-06 10:30:52 +00:00
|
|
|
boolean debug)
|
|
|
|
{
|
2003-05-27 11:04:04 +00:00
|
|
|
Vector entryList = new Vector();
|
|
|
|
String line = "";
|
|
|
|
BufferedReader scenario = null;
|
|
|
|
DescEntry[] entries = null;
|
2003-10-06 11:40:16 +00:00
|
|
|
|
2009-07-06 10:30:52 +00:00
|
|
|
try
|
|
|
|
{
|
2003-05-27 11:04:04 +00:00
|
|
|
scenario = new BufferedReader(new FileReader(url));
|
2009-07-06 10:30:52 +00:00
|
|
|
}
|
|
|
|
catch (java.io.FileNotFoundException fnfe)
|
|
|
|
{
|
2004-05-03 07:48:30 +00:00
|
|
|
System.out.println("Couldn't find file " + url);
|
|
|
|
|
2003-05-27 11:04:04 +00:00
|
|
|
return entries;
|
|
|
|
}
|
2004-05-03 07:48:30 +00:00
|
|
|
|
2009-07-06 10:30:52 +00:00
|
|
|
while (line != null)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
if (line.startsWith("-o"))
|
|
|
|
{
|
2005-06-14 14:42:54 +00:00
|
|
|
String job = line.substring(3, line.length()).trim();
|
2009-07-06 10:30:52 +00:00
|
|
|
DescEntry aEntry;
|
2005-06-14 14:42:54 +00:00
|
|
|
// special in case several Interfaces are given comma separated
|
2009-07-06 10:30:52 +00:00
|
|
|
if (job.indexOf(",") < 0)
|
|
|
|
{
|
2005-06-14 14:42:54 +00:00
|
|
|
aEntry = getDescriptionForSingleJob(job, descPath,
|
2009-07-06 10:30:52 +00:00
|
|
|
debug);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-06-14 14:42:54 +00:00
|
|
|
ArrayList subs = getSubInterfaces(job);
|
|
|
|
String partjob = job.substring(0, job.indexOf(",")).trim();
|
|
|
|
aEntry = getDescriptionForSingleJob(partjob, descPath,
|
2009-07-06 10:30:52 +00:00
|
|
|
debug);
|
2005-06-14 14:42:54 +00:00
|
|
|
|
2009-07-06 10:30:52 +00:00
|
|
|
if (aEntry != null)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < aEntry.SubEntryCount; i++)
|
|
|
|
{
|
2005-06-14 14:42:54 +00:00
|
|
|
String subEntry = aEntry.SubEntries[i].longName;
|
|
|
|
int cpLength = aEntry.longName.length();
|
|
|
|
subEntry = subEntry.substring(cpLength + 2,
|
2009-07-06 10:30:52 +00:00
|
|
|
subEntry.length());
|
2005-06-14 14:42:54 +00:00
|
|
|
|
2009-07-06 10:30:52 +00:00
|
|
|
if (subs.contains(subEntry))
|
|
|
|
{
|
2005-06-14 14:42:54 +00:00
|
|
|
aEntry.SubEntries[i].isToTest = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// DescEntry aEntry = getDescriptionForSingleJob(
|
|
|
|
// line.substring(3).trim(), descPath,
|
|
|
|
// debug);
|
2004-11-02 10:44:57 +00:00
|
|
|
if (aEntry != null)
|
2009-07-06 10:30:52 +00:00
|
|
|
{
|
2004-11-02 10:44:57 +00:00
|
|
|
entryList.add(aEntry);
|
2009-07-06 10:30:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (line.startsWith("-sce"))
|
|
|
|
{
|
2004-05-03 07:48:30 +00:00
|
|
|
DescEntry[] subs = getScenario(line.substring(5,
|
2009-07-06 10:30:52 +00:00
|
|
|
line.length()).trim(), descPath,
|
|
|
|
debug);
|
2004-05-03 07:48:30 +00:00
|
|
|
|
2009-07-06 10:30:52 +00:00
|
|
|
for (int i = 0; i < subs.length; i++)
|
|
|
|
{
|
2003-10-06 11:40:16 +00:00
|
|
|
entryList.add(subs[i]);
|
|
|
|
}
|
2009-07-06 10:30:52 +00:00
|
|
|
}
|
|
|
|
else if (line.startsWith("-p"))
|
|
|
|
{
|
2004-05-03 07:48:30 +00:00
|
|
|
String[] perModule = createScenario(descPath,
|
2009-07-06 10:30:52 +00:00
|
|
|
line.substring(3).trim(), debug);
|
2004-05-03 07:48:30 +00:00
|
|
|
|
2009-07-06 10:30:52 +00:00
|
|
|
for (int i = 0; i < perModule.length; i++)
|
|
|
|
{
|
2004-05-03 07:48:30 +00:00
|
|
|
DescEntry aEntry = getDescriptionForSingleJob(
|
2009-07-06 10:30:52 +00:00
|
|
|
perModule[i].substring(3).trim(),
|
|
|
|
descPath, debug);
|
2004-11-02 10:44:57 +00:00
|
|
|
if (aEntry != null)
|
2009-07-06 10:30:52 +00:00
|
|
|
{
|
2004-11-02 10:44:57 +00:00
|
|
|
entryList.add(aEntry);
|
2009-07-06 10:30:52 +00:00
|
|
|
}
|
2004-05-03 07:48:30 +00:00
|
|
|
}
|
2003-10-06 11:40:16 +00:00
|
|
|
}
|
2004-05-03 07:48:30 +00:00
|
|
|
|
2003-05-27 11:04:04 +00:00
|
|
|
line = scenario.readLine();
|
2009-07-06 10:30:52 +00:00
|
|
|
}
|
|
|
|
catch (java.io.IOException ioe)
|
|
|
|
{
|
|
|
|
if (debug)
|
|
|
|
{
|
2003-05-27 11:04:04 +00:00
|
|
|
System.out.println("Exception while reading scenario");
|
2004-05-03 07:48:30 +00:00
|
|
|
}
|
2003-05-27 11:04:04 +00:00
|
|
|
}
|
|
|
|
}
|
2004-05-03 07:48:30 +00:00
|
|
|
|
2009-07-06 10:30:52 +00:00
|
|
|
try
|
|
|
|
{
|
2003-11-18 15:16:15 +00:00
|
|
|
scenario.close();
|
2009-07-06 10:30:52 +00:00
|
|
|
}
|
|
|
|
catch (java.io.IOException ioe)
|
|
|
|
{
|
|
|
|
if (debug)
|
|
|
|
{
|
2003-11-18 15:16:15 +00:00
|
|
|
System.out.println("Exception while closeing scenario");
|
2004-05-03 07:48:30 +00:00
|
|
|
}
|
2003-11-18 15:16:15 +00:00
|
|
|
}
|
2004-05-03 07:48:30 +00:00
|
|
|
|
2004-11-02 10:44:57 +00:00
|
|
|
if (entryList.size() == 0)
|
2009-07-06 10:30:52 +00:00
|
|
|
{
|
2004-11-02 10:44:57 +00:00
|
|
|
return null;
|
2009-07-06 10:30:52 +00:00
|
|
|
}
|
2003-05-27 11:04:04 +00:00
|
|
|
entries = new DescEntry[entryList.size()];
|
2004-05-03 07:48:30 +00:00
|
|
|
entries = (DescEntry[]) entryList.toArray(entries);
|
|
|
|
|
2003-05-27 11:04:04 +00:00
|
|
|
return entries;
|
|
|
|
}
|
2005-06-14 14:42:54 +00:00
|
|
|
|
2009-07-06 10:30:52 +00:00
|
|
|
protected ArrayList getSubInterfaces(String job)
|
|
|
|
{
|
2005-06-14 14:42:54 +00:00
|
|
|
ArrayList namesList = new ArrayList();
|
|
|
|
StringTokenizer st = new StringTokenizer(job, ",");
|
|
|
|
|
2009-07-06 10:30:52 +00:00
|
|
|
for (int i = 0; st.hasMoreTokens(); i++)
|
|
|
|
{
|
2005-06-14 14:42:54 +00:00
|
|
|
String token = st.nextToken();
|
|
|
|
|
2009-07-06 10:30:52 +00:00
|
|
|
if (token.indexOf(".") < 0)
|
|
|
|
{
|
2005-06-14 14:42:54 +00:00
|
|
|
namesList.add(token);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return namesList;
|
|
|
|
}
|
2004-05-03 07:48:30 +00:00
|
|
|
}
|