added tostring method

This commit is contained in:
fros4943 2008-10-29 18:23:04 +00:00
parent fdcfbd0e62
commit d6fff91861

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: RadioConnection.java,v 1.4 2007/02/28 09:47:55 fros4943 Exp $ * $Id: RadioConnection.java,v 1.5 2008/10/29 18:23:04 fros4943 Exp $
*/ */
package se.sics.cooja; package se.sics.cooja;
@ -39,9 +39,9 @@ import se.sics.cooja.interfaces.Radio;
* A radio connection represents a connection between a source radio and zero or * A radio connection represents a connection between a source radio and zero or
* more destination and interfered radios. Typically the destinations are able * more destination and interfered radios. Typically the destinations are able
* to receive data sent by the source radio, and the interfered radios are not. * to receive data sent by the source radio, and the interfered radios are not.
* *
* @see RadioMedium * @see RadioMedium
* @author Fredrik Osterlind * @author Fredrik Österlind
*/ */
public class RadioConnection { public class RadioConnection {
private Radio source; private Radio source;
@ -52,7 +52,7 @@ public class RadioConnection {
/** /**
* Creates a new radio connection with given source and no destinations. * Creates a new radio connection with given source and no destinations.
* *
* @param sourceRadio * @param sourceRadio
* Source radio * Source radio
*/ */
@ -62,7 +62,7 @@ public class RadioConnection {
/** /**
* Set source of this connection. * Set source of this connection.
* *
* @param radio * @param radio
* Source radio * Source radio
*/ */
@ -72,7 +72,7 @@ public class RadioConnection {
/** /**
* Adds destination radio. * Adds destination radio.
* *
* @param radio * @param radio
* Radio * Radio
*/ */
@ -82,7 +82,7 @@ public class RadioConnection {
/** /**
* Adds interfered radio. * Adds interfered radio.
* *
* @param radio * @param radio
* Radio * Radio
*/ */
@ -92,7 +92,7 @@ public class RadioConnection {
/** /**
* Removes destination radio. * Removes destination radio.
* *
* @param radio * @param radio
* Radio * Radio
*/ */
@ -102,7 +102,7 @@ public class RadioConnection {
/** /**
* Removes interfered radio. * Removes interfered radio.
* *
* @param radio * @param radio
* Radio * Radio
*/ */
@ -125,7 +125,7 @@ public class RadioConnection {
Radio[] radioArray; Radio[] radioArray;
radioArrayType = new Radio[destinations.size()]; radioArrayType = new Radio[destinations.size()];
radioArray = (Radio[]) destinations.toArray(radioArrayType); radioArray = destinations.toArray(radioArrayType);
return radioArray; return radioArray;
} }
@ -138,9 +138,21 @@ public class RadioConnection {
Radio[] radioArray; Radio[] radioArray;
radioArrayType = new Radio[interfered.size()]; radioArrayType = new Radio[interfered.size()];
radioArray = (Radio[]) interfered.toArray(radioArrayType); radioArray = interfered.toArray(radioArrayType);
return radioArray; return radioArray;
} }
public String toString() {
if (destinations.size() == 0) {
return "Radio connection: " + source.getMote() + " -> none";
}
if (destinations.size() == 1) {
return "Radio connection: " + source.getMote() + " -> " + destinations.get(0).getMote();
}
return "Radio connection: " + source.getMote() + " -> " + destinations.size() + " motes";
}
} }