/**
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 *
 * Copyright (C)
 * <a href="http://www.inab.org">Spanish National Institute of Bioinformatics (INB)</a>
 * <a href="http://www.bsc.es">Barcelona Supercomputing Center (BSC)</a>
 * <a href="http://inb.bsc.es">Computational Node 6</a>
 */

package org.inb.biomoby.shared.message;

import java.io.Serializable;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlTransient;

/**
 * @author Dmitry Repchevsky
 */

@XmlTransient
public class AbstractMobyObject extends AbstractMobyElement implements Serializable
{
    private String id;
    private String namespace;
    
    public AbstractMobyObject()
    {
    }
    
    public AbstractMobyObject(String id, String namespace)
    {
        this.id = id;
        this.namespace = namespace;
    }
    
    @XmlAttribute(name="id", namespace="")
    public void setMobyId(String id)
    {
        this.id = id;
    }
    
    public String getMobyId()
    {
        return id == null ? "" : id;
    }
    
    @XmlAttribute(name="namespace", namespace="")
    public void setNamespace(String namespace)
    {
        this.namespace = namespace;
    }
    
    
    public String getNamespace()
    {
        return namespace == null ? "" : namespace;
    }

    // hack around Moby specification bug where it allows attributes with or without namespaces
    // this leads to two attributes in xml schema... these accessors are for JAXB only because
    // they are unaccessible from a client

    @XmlAttribute(name="id", namespace="http://www.biomoby.org/moby")
    void setFixedMobyId(String id)
    {
        this.id = id;
    }
    
    String getFixedMobyId()
    {
        return null; // always return null (we do not want to put it twise)
    }
    
    @XmlAttribute(name="namespace", namespace="http://www.biomoby.org/moby")
    void setMobyNamespace(String namespace)
    {
        this.namespace = namespace;
    }

    String getMobyNamespace()
    {
        return null; // always return null (we do not want to put it twise)
    }

    @Override
    public String toString()
    {
        return this.getClass().getSimpleName();
    }
}
