1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: DescGetter.java,v $
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 ************************************************************************/
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
;
41 * Base Interface to get a description for a given TestJob
44 public abstract class DescGetter
47 public abstract DescEntry
[] getDescriptionFor(String entry
,
51 protected abstract DescEntry
getDescriptionForSingleJob(String job
,
55 protected abstract String
[] createScenario(String descPath
, String job
,
58 protected DescEntry
[] getScenario(String url
, String descPath
,
61 Vector entryList
= new Vector();
63 BufferedReader scenario
= null;
64 DescEntry
[] entries
= null;
68 scenario
= new BufferedReader(new FileReader(url
));
70 catch (java
.io
.FileNotFoundException fnfe
)
72 System
.out
.println("Couldn't find file " + url
);
81 if (line
.startsWith("-o"))
83 String job
= line
.substring(3, line
.length()).trim();
85 // special in case several Interfaces are given comma separated
86 if (job
.indexOf(",") < 0)
88 aEntry
= getDescriptionForSingleJob(job
, descPath
,
93 ArrayList subs
= getSubInterfaces(job
);
94 String partjob
= job
.substring(0, job
.indexOf(",")).trim();
95 aEntry
= getDescriptionForSingleJob(partjob
, descPath
,
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,
107 if (subs
.contains(subEntry
))
109 aEntry
.SubEntries
[i
].isToTest
= true;
114 // DescEntry aEntry = getDescriptionForSingleJob(
115 // line.substring(3).trim(), descPath,
119 entryList
.add(aEntry
);
122 else if (line
.startsWith("-sce"))
124 DescEntry
[] subs
= getScenario(line
.substring(5,
125 line
.length()).trim(), descPath
,
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(),
145 entryList
.add(aEntry
);
150 line
= scenario
.readLine();
152 catch (java
.io
.IOException ioe
)
156 System
.out
.println("Exception while reading scenario");
165 catch (java
.io
.IOException ioe
)
169 System
.out
.println("Exception while closeing scenario");
173 if (entryList
.size() == 0)
177 entries
= new DescEntry
[entryList
.size()];
178 entries
= (DescEntry
[]) entryList
.toArray(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
);