1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 package org.openoffice.xmerge.test;
25 
26 import java.io.IOException;
27 import java.io.InputStream;
28 import java.io.BufferedInputStream;
29 import java.util.Properties;
30 import java.util.Vector;
31 import java.util.Enumeration;
32 
33 /**
34  *  Loads a properties file so that registry knows which plug-ins
35  *  it needs to load.
36  *
37  *  @author: Martin Maher
38  */
39 public class ConverterInfoList {
40 
41     private static String  defaultPropsFile = "ConverterInfoList.properties";
42 
43     private Vector     jars;
44     private Properties props            = null;
45 
46 
47     /**
48      *  This constructor loads and reads the default properties file.
49      *  The default property file name is:
50      *  "ConverterInfoList.properties".
51      *
52      *  @throws  IOException  If any I/O error occurs.
53      */
ConverterInfoList()54     public ConverterInfoList() throws IOException {
55         this(defaultPropsFile);
56     }
57 
58    /**
59     *  This constructor loads and reads the properties file.
60     *
61     *  @param  propsFile  The properties file to load.
62     *
63     *  @throws  IOException  If any I/O error occurs.
64     */
ConverterInfoList(String propsFile)65     public ConverterInfoList(String propsFile) throws IOException {
66 
67         Class c                 = this.getClass();
68         InputStream is          = c.getResourceAsStream(propsFile);
69         BufferedInputStream bis = new BufferedInputStream(is);
70         props                   = new Properties();
71         props.load(bis);
72         bis.close();
73 
74         int i              = 1;
75         String jarFileName = new String();
76         jars               = new Vector();
77 
78         while ((jarFileName = props.getProperty("jarname" + i)) != null) {
79             jars.add(jarFileName);
80             i++;
81         }
82     }
83 
84 
85    /**
86     *  Returns a <code>Vector</code> containing a list of
87     *  <code>String</code> objects.  Each <code>String</code>
88     *  describes a plug-in to be loaded into the registry.
89     *
90     *
91     *  @return  A <code>Vector</code> containing a list of
92     *           <code>String</code> objects.  Each
93     *           <code>String</code> describes a plug-in to be
94     *           loaded into the registry.
95     */
getJarFileEnum()96     public Enumeration getJarFileEnum() {
97 
98         return jars.elements();
99     }
100 }
101 
102