/* XBN Java: Generically useful, non-GUI Java code. http://sourceforge.net/projects/xbnjava Copyright (C) 1997-2003, Jeff Epstein All rights reserved. Modifications: No Redistribution in binary form, with or without modifications, are permitted provided that the following conditions are met: * 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. * If modifications are made to source code then this license should indicate that fact in the "Modifications" section above. * Neither the author, nor the contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. [NOTE: This license contains NO advertising clause.] */ package xbn.util; import xbn.XBNObject; /**

The base class for all things implementing xbn.util.LockOneWay. Has standardized functions that throw LockedExceptions.

Source code:  XBNLocked.java.

@version 0.9b @author Jeff Epstein, http://sourceforge.net/projects/xbnjava. **/ public abstract class XBNLocked extends XBNObject { /**

Throw a LockedException.

Equal to throw new LockedException(getXMsgPrefix() + s_funcBody)

@param s_funcBody The throwing function name and error message body. **/ protected final void throwLX(String s_funcBody) { throw new LockedException(getXMsgPrefix() + s_funcBody); } /**

Throw a LockedException.

If s_name is not null, this equals throw new LockedException(getXMsgPrefix() + s_callingFunc + " [name=" + s_name + "]: " + s_lockedMsg))

If s_name is null, this equals throw new LockedException(getXMsgPrefix() + s_callingFunc + ": " + s_lockedMsg))

**/ protected final void throwLX(String s_callingFunc, String s_name, String s_lockedMsg) { String sNamePart = ((s_name == null) ? sES : " [name=" + s_name + "]"); throw new LockedException(getXMsgPrefix() + s_callingFunc + sNamePart + ": " + s_lockedMsg); } /**

If locked, throw a LockedException. Otherwise, do nothing.

If b_locked then this equals throwLX(s_callingFunc + ": isLocked() equals true.")

@param b_locked If true, then this class is locked. If false, it is not locked. @param s_callingFunc The name of the function that will throw this error. **/ protected final void throwLXIfLocked(boolean b_locked, String s_callingFunc) { if(b_locked) { throwLX(s_callingFunc + ": isLocked() equals true."); } } /**

If locked, throw a LockedException. Otherwise, do nothing.

If b_locked then this equals throwLX(s_callingFunc, s_name, s_lockedMsg)

**/ protected final void throwLXIfLocked(boolean b_locked, String s_callingFunc, String s_name) { if(b_locked) { throwLX(s_callingFunc, s_name, "isLocked() equals true."); } } /**

If locked, throw a LockedException. Otherwise, do nothing.

If b_locked then this equals throwLX(s_callingFunc, s_name, s_lockedMsg)

**/ protected final void throwLXIfLocked(boolean b_locked, String s_callingFunc, String s_name, String s_lockedMsg) { if(b_locked) { throwLX(s_callingFunc, s_name, s_lockedMsg); } } /**

If unlocked, throw a LockedException. Otherwise, do nothing.

If b_locked equals false, then this equals throwLX(s_callingFunc + ": isLocked() equals false.")

@param b_locked If false, then this class is not locked. If true, it is locked. @param s_callingFunc The name of the function that will throw this error. **/ protected final void throwLXIfUnlocked(boolean b_locked, String s_callingFunc) { if(!b_locked) { throwLX(s_callingFunc + ": isLocked() equals false."); } } }