All Downloads are FREE. Search and download functionalities are using the official Maven repository.

at.spardat.xma.boot.comp.data.XMASWTDescription Maven / Gradle / Ivy

/*******************************************************************************
 * Copyright (c) 2003, 2007 s IT Solutions AT Spardat GmbH .
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     s IT Solutions AT Spardat GmbH - initial API and implementation
 *******************************************************************************/

/*
 * @(#) $Id: XMASWTDescription.java 2084 2007-11-27 14:53:31Z s3460 $
 */
package at.spardat.xma.boot.comp.data;

import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;

import at.spardat.xma.boot.comp.DTDStatics;

/**
 * This class represents the swt-description tag from xma-app.xml.
 * It may contain an ordered list of prefered versions and a set of
 * resources to download if none of the prefered versions is installed.
 * @author s2877
 */
public class XMASWTDescription {

    /** Ordered List of preinstalled swt-versions to use. Contains SWTPreinstall objects */
    private List preinstalls = new ArrayList();

    /** Map of resources to download if none of the preinstalls is found
     *  in the xma-installation. Contains XMAResource objects */
    private HashMap resources = new HashMap();

    /** Constructor, empty */
    XMASWTDescription() {
    }

    /**
     * write this object to a xml print stream.
     *
     * @param ps the PrintStream to write to
     */
    public void writeXML( PrintStream ps ) {
        ps.print( DTDStatics.OPEN + DTDStatics.SWT_DESCRIPTION + DTDStatics.CLOSE );
        for (Iterator iter = preinstalls.iterator(); iter.hasNext();) {
            SWTPreinstall element = (SWTPreinstall)iter.next();
            ps.print("   "); //$NON-NLS-1$
            element.writeXML(ps);
            ps.println();

        }
        for (Iterator iter = resources.values().iterator(); iter.hasNext();) {
            XMAResource element = (XMAResource)iter.next();
            ps.print("   "); //$NON-NLS-1$
            element.writeXML(ps);
            ps.println();

        }
        ps.println( DTDStatics.OPEN + DTDStatics.CLOSE_CHAR + DTDStatics.SWT_DESCRIPTION + DTDStatics.CLOSE );
    }

    /** adds the given preinstall to the list preinstalls */
    public void addPreinstall(SWTPreinstall preinstall) {
        preinstalls.add(preinstall);
    }

    /** adds the given resource to the map resources */
    public void addResource( XMAResource resoure ) {
        resources.put( resoure.getHref_(), resoure);
    }

    /** returns the list of preinstalls, containing SWTPreinstall objects */
    public List getPreinstalls() {
        return preinstalls;
    }

    /** returns the map of resources, containing XMAResource objects */
    public HashMap getResources() {
        return resources;
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy