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

org.objectweb.dream.protocol.bus.BusExportIdentifier Maven / Gradle / Ivy

/**
 * Dream
 * Copyright (C) 2003-2004 INRIA Rhone-Alpes
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * Contact: [email protected]
 *
 * Initial developer(s): Matthieu Leclercq
 * Contributor(s): 
 */

package org.objectweb.dream.protocol.bus;

import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;

import org.objectweb.dream.protocol.ExportIdentifier;
import org.objectweb.dream.util.Util;

/**
 * Export identifier for bus protocol. Contains only an array of lower export
 * identifier.
 */
public class BusExportIdentifier implements ExportIdentifier, Externalizable
{

  private static final long    serialVersionUID = 1418964167347517947L;
  protected ExportIdentifier[] ids;

  /**
   * Constructor
   * 
   * @param lowerIds the array of identifier use to access every protocol
   *          instance in the bus.
   */
  public BusExportIdentifier(ExportIdentifier[] lowerIds)
  {
    if (lowerIds == null)
    {
      throw new NullPointerException();
    }
    ids = lowerIds;
  }

  // ---------------------------------------------------------------------------
  // Implementation of the ExportIdentifier interface
  // ---------------------------------------------------------------------------

  /**
   * @see ExportIdentifier#getNextExportIds()
   */
  public ExportIdentifier[] getNextExportIds()
  {
    return ids;
  }

  // ---------------------------------------------------------------------------
  // Implementation of the Externalizable interface
  // ---------------------------------------------------------------------------

  /**
   * @see Externalizable#readExternal(ObjectInput)
   */
  public void readExternal(ObjectInput in) throws IOException,
      ClassNotFoundException
  {
    int length = in.readInt();
    ids = new ExportIdentifier[length];
    for (int i = 0; i < ids.length; i++)
    {
      ids[i] = (ExportIdentifier) Util.readObject(in);
    }
  }

  /**
   * @see Externalizable#writeExternal(ObjectOutput)
   */
  public void writeExternal(ObjectOutput out) throws IOException
  {
    out.writeInt(ids.length);
    for (int i = 0; i < ids.length; i++)
    {
      Util.writeObject(out, ids[i]);
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy