/* 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; import xbn.named.Named; import xbn.string.UtilString; /**
Configuration for a single "level" of output, consisting of a MsgFormat and on/off state. This is for use in Outputter.
Source code: OConfig.java
A OConfig contains three elements:
Create an OConfig.
Equal to OConfig(false)
Create an OConfig.
Equal to OConfig((new MFPlain()), b_on)
Create an OConfig.
Equal to OConfig(msg_format, false)
Create an OConfig.
Equal to OConfig(null, msg_format, b_on)
Create an OConfig.
@param s_name The name of this OConfig object. See getName. @param msg_format The MsgFormat. See setMsgFormat and getMsgFormat . @param b_on If true, this output level is on. If false, this output level is off. See setOn and isOn. **/ public OConfig(String s_name, MsgFormat msg_format, boolean b_on) { sName = s_name; setMsgFormat(msg_format); setOn(b_on); } /**Set the MsgFormat.
@param msg_format The MsgFormat. May not be null. If no prefix is desired, set this to(new MFPlain())
.
**/
public final void setMsgFormat(MsgFormat msg_format) {
throwAXIfNull(msg_format, "msg_format", "setMsgFormat");
msgFormat = msg_format;
}
/**
Get the MsgFormat for direct manipulation.
**/ public MsgFormat getMsgFormat() { return msgFormat; } /**Turn this OConfig output level on or off.
Get with isOn.
Is this OConfig output level on or off?
Set with setOn.
This setting is only notification for external classes, it does not directly affect (nor is used by) anything in this class.
@return true If this output level is on.Given the provided message body, what is the full message?
@param s_message The body of the message. @returngetMsgFormat().getFormatted(b_useIndent, s_message)
**/
public String getFormatted(boolean b_useIndent, String s_message) {
return getMsgFormat().getFormatted(b_useIndent, s_message);
}
/**
Get some information about this OConfig object.
**/ public String toString() { return "OConfig: " + (new UtilString()).getConditional("getName()=", sName, ", ") + "isOn()=" + isOn() + ", [" + getMsgFormat().toString() + "]"; } //REQUIRED BY xbn.named.Named...START public String getName() { return sName; } //REQUIRED BY xbn.named.Named...END }