/********************************************************************************
*
* JOrocos Library
*
* Copyright (c) 2011
* All rights reserved.
*
* Luca Gherardi
* University of Bergamo
* Dept. of Information Technology and Mathematics
*
* -------------------------------------------------------------------------------
*
* File: WrongPortTypeExistException.java
* Created: Jul 27, 2011
*
* Author: <A HREF="mailto:luca.gherardi@unibg.it">Luca Gherardi</A>
*
* Supervised by: <A HREF="mailto:brugali@unibg.it">Davide Brugali</A>
*
* In cooperation with: <A HREF="mailto:herman.bruyninckx@mech.kuleuven.be">Herman Bruyninckx</A>
*
* -------------------------------------------------------------------------------
*
* This sofware is published under a dual-license: GNU Lesser General Public
* License LGPL 2.1 and BSD license. The dual-license implies that users of this
* code may choose which terms they prefer.
*
* -------------------------------------------------------------------------------
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the University of Bergamo nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License LGPL as
* published by the Free Software Foundation, either version 2.1 of the
* License, or (at your option) any later version or the BSD license.
*
* This program 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 LGPL and the BSD license for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License LGPL and BSD license along with this program.
*
*******************************************************************************/
package it.unibg.robotics.jorocos.exceptions;
import it.unibg.robotics.jorocos.core.AbstractOrocosComponent;
import it.unibg.robotics.jorocos.core.OrocosDataPort;
import it.unibg.robotics.jorocos.core.OrocosDataPort.PortType;
/**
* Thrown when someone tries to use an {@link OrocosDataPort} in a way that is not allowed
* for that port type (e.g. call the method
* {@link AbstractOrocosComponent#createDataConnectionToInputPort(String, it.unibg.robotics.jorocos.core.AbstractOrocosConnection.LockPolicy, Object)}).
* on an output port.
*
* @author <A HREF="mailto:luca.gherardi@unibg.it">Luca Gherardi</A>
* @version 1.0
* @since August 2011
*/
public class WrongPortTypeException extends Exception{
/** The Constant serialVersionUID. */
private static final long serialVersionUID = 1L;
/** The port data type. */
private PortType type;
/**
* Instantiates a WrongPortTypeException.
*
* @param type the port data type
*/
public WrongPortTypeException(PortType type) {
super();
this.type = type;
}
/* (non-Javadoc)
* @see java.lang.Throwable#toString()
*/
public String toString(){
if(type == PortType.INPUT_PORT){
return "You are trying to read from an input port. It's not possible.";
}else{
return "You are trying to write on an output port. It's not possible.";
}
}
}