2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A/*
2N/A * Copyright (c) 2001 by Sun Microsystems, Inc.
2N/A * All rights reserved.
2N/A */
2N/A
2N/A//
2N/A// Assert.java : Handles assertions in a central fashion.
2N/A//
2N/A// Author: Erik Guttman
2N/A//
2N/A//
2N/A
2N/Apackage com.sun.slp;
2N/A
2N/Aimport java.util.*;
2N/Aimport java.text.*;
2N/A
2N/A/**
2N/A * The Assert class is used to test assertions and end the program
2N/A * execution if the assertion fails.
2N/A *
2N/A * @author Erik Guttman
2N/A */
2N/A
2N/Aclass Assert {
2N/A static void slpassert(boolean bool, String msgTag, Object[] params) {
2N/A if (bool == false) {
2N/A SLPConfig conf = SLPConfig.getSLPConfig();
2N/A printMessageAndDie(conf, msgTag, params);
2N/A }
2N/A }
2N/A
2N/A // Print message and die. Used within SLPConfig during initialization.
2N/A static void
2N/A printMessageAndDie(SLPConfig conf, String msgTag, Object[] params) {
2N/A ResourceBundle msgs = conf.getMessageBundle(conf.getLocale());
2N/A String failed = msgs.getString("assert_failed");
2N/A String msg = conf.formatMessage(msgTag, params);
2N/A System.err.println(failed+msg);
2N/A (new Exception()).printStackTrace(); // tells where we are at...
2N/A System.exit(-1);
2N/A }
2N/A
2N/A // Assert that a parameter is nonnull.
2N/A // Throw IllegalArgumentException if so.
2N/A
2N/A static void nonNullParameter(Object obj, String param) {
2N/A if (obj == null) {
2N/A SLPConfig conf = SLPConfig.getSLPConfig();
2N/A String msg =
2N/A conf.formatMessage("null_parameter", new Object[] {param});
2N/A throw
2N/A new IllegalArgumentException(msg);
2N/A }
2N/A }
2N/A}