001/*
002 * IzPack - Copyright 2001-2005 Julien Ponge, All Rights Reserved.
003 * 
004 * http://www.izforge.com/izpack/
005 * http://developer.berlios.de/projects/izpack/
006 * 
007 * Copyright 2005 Klaus Bartz
008 * 
009 * Licensed under the Apache License, Version 2.0 (the "License");
010 * you may not use this file except in compliance with the License.
011 * You may obtain a copy of the License at
012 * 
013 *     http://www.apache.org/licenses/LICENSE-2.0
014 *     
015 * Unless required by applicable law or agreed to in writing, software
016 * distributed under the License is distributed on an "AS IS" BASIS,
017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018 * See the License for the specific language governing permissions and
019 * limitations under the License.
020 */
021
022package com.izforge.izpack.util;
023
024import com.izforge.izpack.installer.AutomatedInstallData;
025
026/*---------------------------------------------------------------------------*/
027/**
028 * This class is the system independent base class for helpers which are system dependent in its
029 * subclasses.
030 * 
031 * @author Klaus Bartz
032 */
033/*---------------------------------------------------------------------------*/
034public class OSClassHelper
035{
036
037    protected AutomatedInstallData installdata;
038
039    protected Class workerClass = null;
040
041    protected Object worker = null;
042
043    /**
044     * Default constructor
045     */
046    public OSClassHelper()
047    {
048        super();
049    }
050
051    /**
052     * Creates an object which contains as worker an object of the given class name if possible. If
053     * not possible, only the stack trace will be printed, no exception will be raised. To determine
054     * the state, there is the method good.
055     * 
056     * @param className full qualified class name of the needed worker
057     */
058    public OSClassHelper(String className)
059    {
060        super();
061
062        try
063        {
064            workerClass = Class.forName(className);
065            worker = workerClass.newInstance();
066        }
067        catch (InstantiationException e)
068        {
069            e.printStackTrace();
070        }
071        catch (IllegalAccessException e)
072        {
073            e.printStackTrace();
074        }
075        catch (ClassNotFoundException e)
076        {
077            e.printStackTrace();
078            // Do nothing, class not bound.
079        }
080        catch (Exception e4)
081        {   // If the native lib is not found an unqualified Exception will be raised.
082            Debug.trace("Ctor OSClassHelper for " + className + ": worker not available (" + e4.getMessage() + ").");
083            return;
084        }
085        Debug.trace("Ctor OSClassHelper for " + className + " is good: " + good());
086
087    }
088
089    public boolean good()
090    {
091        return (worker != null ? true : false);
092    }
093
094    public boolean verify(AutomatedInstallData idata) throws Exception
095    {
096        installdata = idata;
097        return (false);
098    }
099
100}