KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > izforge > izpack > util > OSClassHelper


1 /*
2  * IzPack - Copyright 2001-2007 Julien Ponge, All Rights Reserved.
3  *
4  * http://www.izforge.com/izpack/
5  * http://developer.berlios.de/projects/izpack/
6  *
7  * Copyright 2005 Klaus Bartz
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */

21
22 package com.izforge.izpack.util;
23
24 import com.izforge.izpack.installer.AutomatedInstallData;
25
26 /*---------------------------------------------------------------------------*/
27 /**
28  * This class is the system independent base class for helpers which are system dependent in its
29  * subclasses.
30  *
31  * @author Klaus Bartz
32  */

33 /*---------------------------------------------------------------------------*/
34 public class OSClassHelper
35 {
36
37     protected AutomatedInstallData installdata;
38
39     protected Class JavaDoc workerClass = null;
40
41     protected Object JavaDoc worker = null;
42
43     /**
44      * Default constructor
45      */

46     public OSClassHelper()
47     {
48         super();
49     }
50
51     /**
52      * Creates an object which contains as worker an object of the given class name if possible. If
53      * not possible, only the stack trace will be printed, no exception will be raised. To determine
54      * the state, there is the method good.
55      *
56      * @param className full qualified class name of the needed worker
57      */

58     public OSClassHelper(String JavaDoc className)
59     {
60         super();
61
62         try
63         {
64             workerClass = Class.forName(className);
65             worker = workerClass.newInstance();
66         }
67         catch (InstantiationException JavaDoc e)
68         {
69             e.printStackTrace();
70         }
71         catch (IllegalAccessException JavaDoc e)
72         {
73             e.printStackTrace();
74         }
75         catch (ClassNotFoundException JavaDoc e)
76         {
77             e.printStackTrace();
78             // Do nothing, class not bound.
79
}
80         catch (Exception JavaDoc e4)
81         { // If the native lib is not found an unqualified Exception will be raised.
82
Debug.trace("Ctor OSClassHelper for " + className + ": worker not available (" + e4.getMessage() + ").");
83             return;
84         }
85         Debug.trace("Ctor OSClassHelper for " + className + " is good: " + good());
86
87     }
88
89     /**
90      * Return whether the helper can do the work or not.
91      * @return whether the helper can do the work or not
92      */

93     public boolean good()
94     {
95         return (worker != null);
96     }
97
98     /**
99      * Verifies the helper.
100      * @param idata current install data
101      * @return whether the helper is good or not
102      * @throws Exception
103      */

104     public boolean verify(AutomatedInstallData idata) throws Exception JavaDoc
105     {
106         installdata = idata;
107         return (false);
108     }
109
110 }
111
Popular Tags