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

at.spardat.xma.mdl.AtomTransferServer Maven / Gradle / Ivy

The newest version!
/*******************************************************************************
 * 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: AtomTransferServer.java 2246 2008-01-03 09:22:50Z s2877 $
package at.spardat.xma.mdl;

import at.spardat.xma.plugins.PluginManagerServer;

/**
 * Provides functionality to convert between {@link IAtomic}s and attribute classes and types.
 * This functionality is extendable by an optional plugin for {@link IAtomTransfer}.
 *
 * @author YSD, GUB
 */
public class AtomTransferServer {

    /** optional atom transver plugin */
    static private IAtomTransfer plugin;

    /**
     * Calculates the plugin variable
     */
    static {
        PluginManagerServer pluginManager = PluginManagerServer.getInstance();
        if(pluginManager.isPluginDeclared(IAtomTransfer.class)) {
            plugin = (IAtomTransfer) pluginManager.getPlugin(IAtomTransfer.class);
        }
    }

    /**
     * Constructs an Atom from an Object.
     * If a plugin for {@link IAtomTransfer} is configured, it is used.
     * Otherwise it just uses {@link Atom#newInstance(java.lang.Object) Atom.newInstance(o)}.
     *
     * @exception IllegalArgumentException if the provided Object is of unsupported type
     */
    public static Atom newInstance (Object o) {
        if (o == null) throw new IllegalArgumentException();
        if(plugin!=null) {
            return plugin.newInstance(o);
        } else {
            return Atom.newInstance(o);
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy