umontreal.iro.lecuyer.rng.RandomStreamInstantiationException Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ssj Show documentation
Show all versions of ssj Show documentation
SSJ is a Java library for stochastic simulation, developed under the direction of Pierre L'Ecuyer,
in the Département d'Informatique et de Recherche Opérationnelle (DIRO), at the Université de Montréal.
It provides facilities for generating uniform and nonuniform random variates, computing different
measures related to probability distributions, performing goodness-of-fit tests, applying quasi-Monte
Carlo methods, collecting (elementary) statistics, and programming discrete-event simulations with both
events and processes.
The newest version!
/*
* Class: RandomStreamInstantiationException
* Description: thrown when a random stream factory cannot instantiate a stream
* Environment: Java
* Software: SSJ
* Copyright (C) 2001 Pierre L'Ecuyer and Université de Montréal
* Organization: DIRO, Université de Montréal
* @author
* @since
* SSJ is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License (GPL) as published by the
* Free Software Foundation, either version 3 of the License, or
* any later version.
* SSJ 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 General Public License for more details.
* A copy of the GNU General Public License is available at
GPL licence site.
*/
package umontreal.iro.lecuyer.rng;
/**
* This exception is thrown when a random stream factory cannot instantiate a stream
* on a call to its {@link umontreal.iro.lecuyer.rng.RandomStreamFactory#newInstance(()) newInstance} method.
*
*/
public class RandomStreamInstantiationException extends RuntimeException {
private RandomStreamFactory factory;
/**
* Constructs a new random stream instantiation exception with
* no message, no cause, and thrown by the given factory.
*
* @param factory the random stream factory which thrown the exception.
*
*
*/
public RandomStreamInstantiationException (RandomStreamFactory factory) {
super();
this.factory = factory;
}
/**
* Constructs a new random stream instantiation exception with
* the given message, no cause, and concerning factory.
*
* @param factory the random stream factory concerned by the exception.
*
* @param message the error message describing the exception.
*
*
*/
public RandomStreamInstantiationException (RandomStreamFactory factory,
String message) {
super (message);
this.factory = factory;
}
/**
* Constructs a new random stream instantiation exception with
* no message, the given cause, and concerning factory.
*
* @param factory the random stream factory concerned by the exception.
*
* @param cause the cause of the exception.
*
*
*/
public RandomStreamInstantiationException (RandomStreamFactory factory,
Throwable cause) {
super (cause);
this.factory = factory;
}
/**
* Constructs a new random stream instantiation exception with
* the given message, the supplied cause,
* and concerning factory.
*
* @param factory the random stream factory concerned by the exception.
*
* @param message the error message describing the exception.
*
* @param cause the cause of the exception.
*
*
*/
public RandomStreamInstantiationException (RandomStreamFactory factory,
String message, Throwable cause) {
super (message, cause);
this.factory = factory;
}
/**
* Returns the random stream factory concerned by this exception.
*
* @return the random stream factory concerned by this exception.
*
*/
public RandomStreamFactory getRandomStreamFactory() {
return factory;
}
/**
* Returns a short description of the exception.
* If {@link #getRandomStreamFactory(()) getRandomStreamFactory} returns null,
* this calls super.toString. Otherwise, the
* result is the concatenation of:
*
* a) the name of the actual class of the exception;
*
* b) the string ": For random stream factory ";
*
* c) the result of {@link #getRandomStreamFactory(()) getRandomStreamFactory}.toString();
*
* d) if {@link java.lang.Throwable#getMessage(()) getMessage} is non-null,
* ", " followed by the result of
* {@link java.lang.Throwable#getMessage(()) getMessage}.
*
* @return a string representation of the exception.
*/
public String toString() {
if (factory == null)
return super.toString();
StringBuffer sb = new StringBuffer (getClass().getName());
sb.append (": For random stream factory ");
sb.append (factory.toString());
String msg = getMessage();
if (msg != null)
sb.append (", ").append (msg);
return sb.toString();
}
}