/* 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.output; import xbn.XBNObject; /**
Random functions relating to xbn.output.
Source code: UtilOutput.java.
Create a UtilOutput. This constructor does nothing.
**/ public UtilOutput() { } /**Create an Outputter containing the provided OWriter.
@returngetOptrFromOW(o_writer, "o_writer", "xbn.output.UtilOutput.getOptrFromOW")
**/
public final Outputter getOptrFromOW(OWriter o_writer) {
return getOptrFromOW(o_writer, "o_writer", "xbn.output.UtilOutput.getOptrFromOW");
}
/**
Create an Outputter containing the provided OWriter.
@returngetOptrFromOW(o_writer, (new MFPlain()), s_owriterName, s_callingClsFnc)
**/
public final Outputter getOptrFromOW(OWriter o_writer, String s_owriterName, String s_callingClsFnc) {
return getOptrFromOW(o_writer, (new MFPlain()), s_owriterName, s_callingClsFnc);
}
/**
Create an Outputter containing the provided OWriter.
@param o_writer The OWriter the returned Outputter should contain. May not be null. @param msg_format The MsgFormat object the returned Outputter should contain. May not be null. @param s_owriterName The descriptive name of o_writer, for the sake of potential error messages only. @param s_callingClsFnc The class-name-dot-function that this function is being called from, for the sake of potential error messages only. @return(new Outputter(o_writer, (new OConfig(msg_format, true))))
**/
public final Outputter getOptrFromOW(OWriter o_writer, MsgFormat msg_format, String s_owriterName, String s_callingClsFnc) {
if(o_writer == null) {
throwAX(s_callingClsFnc + ": " + s_owriterName + " is null.");
}
if(msg_format == null) {
throwAX(s_callingClsFnc + ": msg_format is null.");
}
if(!o_writer.isActive()) {
return (new Outputter());
}
return (new Outputter(o_writer, (new OConfig(msg_format, true))));
}
/**
Either throw an AssertException or just debug the error message.
@param s_error The error message. May not be null, or zero characters in length. @param optr_dbg The Outputter to (potentially) output s_error with. May not be null. If this is on the s_error is output, and no exception is thrown. Otherwise, an AssertException is thrown. **/ public final void throwAXOrDebug(String s_error, Outputter optr_dbg) { throwAXIfBadStr(s_error, "s_error", "throwAXOrDebug"); throwAXIfNull(optr_dbg, "optr_dbg (original error: '" + s_error + "')", "throwAXOrDebug"); if(optr_dbg.getOConfig().isOn()) { optr_dbg.write("ERROR -- " + s_error); } else { throwAX(s_error); } } }