| <html> |
| <head> |
| <title> |
| log4cxx - Documentation |
| </title> |
| <link href="../css/doxygen.css" rel="stylesheet" type="text/css"/> |
| </head> |
| |
| <body bgcolor="#ffffff" text="#000000" link="#525D76"> |
| <!-- START Header table --> |
| <table border="0" cellspacing="0" width="90%"> |
| <!-- TOP IMAGE --> |
| <tr> |
| <td colspan="2"> |
| <a href="http://logging.apache.org"> |
| <img src="http://logging.apache.org/images/ls-logo.jpg" align="left" border="0"/> |
| </a> |
| </td> |
| |
| </tr> |
| </table> |
| <!-- END Header table --> |
| |
| <!-- START main table --> |
| <table id="main" border="0" width="90%" cellspacing="2" cellpadding="0"> |
| <tr><td colspan="2"> |
| <hr noshade="" size="1"/> |
| </td></tr> |
| |
| <tr> |
| <!-- LEFT SIDE NAVIGATION --> |
| <td id="navbar" valign="top"> |
| <!-- ============================================================ --> |
| <table id="navbar" border="0" cellspacing="0" cellpadding="0"> |
| <tr > |
| <td class="navbarHeader" nowrap="true"> |
| <strong>Apache</strong> |
| </td> |
| </tr> |
| <tr><td class="navbarItem"><small> <a href="http://www.apache.org">Apache Home</a> |
| </small></td></tr> |
| <tr><td class="navbarItem"><small> <a href="http://logging.apache.org/">Logging Services</a> |
| </small></td></tr> |
| <tr > |
| <td class="navbarHeader" nowrap="true"> |
| <strong>log4cxx project</strong> |
| </td> |
| </tr> |
| <tr><td class="navbarItem"><small> <a href="../index.html">About</a> |
| </small></td></tr> |
| <tr><td class="navbarItem"><small> <a href="../news.html">News</a> |
| </small></td></tr> |
| <tr><td class="navbarItem"><small> <a href="../team.html">Team</a> |
| </small></td></tr> |
| <tr><td class="navbarItem"><small> <a href="../manual/index.html">Documentation</a> |
| </small></td></tr> |
| <tr><td class="navbarItem"><small> <a href="../performance.html">Performance</a> |
| </small></td></tr> |
| <tr><td class="navbarItem"><small> <a href="../download.html">Download</a> |
| </small></td></tr> |
| </table> |
| |
| </td> |
| <td id="mainContents" align="left" valign="top"> |
| <hr> |
| <!-- Generated by Doxygen 1.3.5 --> |
| <div class="qindex"><a class="qindex" href="index.html">Main Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="hierarchy.html">Class Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical List</a> | <a class="qindex" href="annotated.html">Class List</a> | <a class="qindex" href="functions.html">Class Members</a></div> |
| <h1>OptionConverter Class Reference</h1><a href="classlog4cxx_1_1helpers_1_1OptionConverter-members.html">List of all members.</a><table border=0 cellpadding=0 cellspacing=0> |
| <tr><td></td></tr> |
| <tr><td colspan=2><br><h2>Static Public Member Functions</h2></td></tr> |
| <tr><td class="memItemLeft" nowrap align=right valign=top>bool </td><td class="memItemRight" valign=bottom><a class="el" href="classlog4cxx_1_1helpers_1_1OptionConverter.html#e1">toBoolean</a> (const String &value, bool dEfault)</td></tr> |
| |
| <tr><td class="memItemLeft" nowrap align=right valign=top>String </td><td class="memItemRight" valign=bottom><a class="el" href="classlog4cxx_1_1helpers_1_1OptionConverter.html#e5">findAndSubst</a> (const String &key, Properties &props)</td></tr> |
| |
| <tr><td class="memItemLeft" nowrap align=right valign=top>String </td><td class="memItemRight" valign=bottom><a class="el" href="classlog4cxx_1_1helpers_1_1OptionConverter.html#e6">substVars</a> (const String &val, Properties &props)</td></tr> |
| |
| <tr><td class="memItemLeft" nowrap align=right valign=top>String </td><td class="memItemRight" valign=bottom><a class="el" href="classlog4cxx_1_1helpers_1_1OptionConverter.html#e7">getSystemProperty</a> (const String &key, const String &def)</td></tr> |
| |
| <tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="classlog4cxx_1_1helpers_1_1ObjectPtrT.html">ObjectPtr</a> </td><td class="memItemRight" valign=bottom><a class="el" href="classlog4cxx_1_1helpers_1_1OptionConverter.html#e8">instantiateByClassName</a> (const String &className, const Class &superClass, const <a class="el" href="classlog4cxx_1_1helpers_1_1ObjectPtrT.html">ObjectPtr</a> &defaultValue)</td></tr> |
| |
| <tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="classlog4cxx_1_1helpers_1_1OptionConverter.html#e10">selectAndConfigure</a> (const String &configFileName, const String &clazz, <a class="el" href="classlog4cxx_1_1helpers_1_1ObjectPtrT.html">spi::LoggerRepositoryPtr</a> &hierarchy)</td></tr> |
| |
| </table> |
| <hr><a name="_details"></a><h2>Detailed Description</h2> |
| A convenience class to convert property values to specific types. |
| <p> |
| <hr><h2>Member Function Documentation</h2> |
| <a class="anchor" name="e5" doxytag="log4cxx::helpers::OptionConverter::findAndSubst" ></a><p> |
| <table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> |
| <tr> |
| <td class="mdRow"> |
| <table cellpadding="0" cellspacing="0" border="0"> |
| <tr> |
| <td class="md" nowrap valign="top"> String findAndSubst </td> |
| <td class="md" valign="top">( </td> |
| <td class="md" nowrap valign="top">const String & </td> |
| <td class="mdname" nowrap> <em>key</em>, </td> |
| </tr> |
| <tr> |
| <td></td> |
| <td></td> |
| <td class="md" nowrap>Properties & </td> |
| <td class="mdname" nowrap> <em>props</em></td> |
| </tr> |
| <tr> |
| <td></td> |
| <td class="md">) </td> |
| <td class="md" colspan="2"><code> [static]</code></td> |
| </tr> |
| |
| </table> |
| </td> |
| </tr> |
| </table> |
| <table cellspacing=5 cellpadding=0 border=0> |
| <tr> |
| <td> |
| |
| </td> |
| <td> |
| |
| <p> |
| Find the value corresponding to <code>key</code> in <code>props</code>. Then perform variable substitution on the found value. </td> |
| </tr> |
| </table> |
| <a class="anchor" name="e7" doxytag="log4cxx::helpers::OptionConverter::getSystemProperty" ></a><p> |
| <table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> |
| <tr> |
| <td class="mdRow"> |
| <table cellpadding="0" cellspacing="0" border="0"> |
| <tr> |
| <td class="md" nowrap valign="top"> String getSystemProperty </td> |
| <td class="md" valign="top">( </td> |
| <td class="md" nowrap valign="top">const String & </td> |
| <td class="mdname" nowrap> <em>key</em>, </td> |
| </tr> |
| <tr> |
| <td></td> |
| <td></td> |
| <td class="md" nowrap>const String & </td> |
| <td class="mdname" nowrap> <em>def</em></td> |
| </tr> |
| <tr> |
| <td></td> |
| <td class="md">) </td> |
| <td class="md" colspan="2"><code> [static]</code></td> |
| </tr> |
| |
| </table> |
| </td> |
| </tr> |
| </table> |
| <table cellspacing=5 cellpadding=0 border=0> |
| <tr> |
| <td> |
| |
| </td> |
| <td> |
| |
| <p> |
| <dl compact><dt><b>Parameters:</b></dt><dd> |
| <table border="0" cellspacing="2" cellpadding="0"> |
| <tr><td valign=top><em>key</em> </td><td>The key to search for. </td></tr> |
| <tr><td valign=top><em>def</em> </td><td>The default value to return. </td></tr> |
| </table> |
| </dl> |
| <dl compact><dt><b>Returns:</b></dt><dd>the string value of the system property, or the default value if there is no property with that key.</dd></dl> |
| </td> |
| </tr> |
| </table> |
| <a class="anchor" name="e8" doxytag="log4cxx::helpers::OptionConverter::instantiateByClassName" ></a><p> |
| <table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> |
| <tr> |
| <td class="mdRow"> |
| <table cellpadding="0" cellspacing="0" border="0"> |
| <tr> |
| <td class="md" nowrap valign="top"> <a class="el" href="classlog4cxx_1_1helpers_1_1ObjectPtrT.html">ObjectPtr</a> instantiateByClassName </td> |
| <td class="md" valign="top">( </td> |
| <td class="md" nowrap valign="top">const String & </td> |
| <td class="mdname" nowrap> <em>className</em>, </td> |
| </tr> |
| <tr> |
| <td></td> |
| <td></td> |
| <td class="md" nowrap>const Class & </td> |
| <td class="mdname" nowrap> <em>superClass</em>, </td> |
| </tr> |
| <tr> |
| <td></td> |
| <td></td> |
| <td class="md" nowrap>const <a class="el" href="classlog4cxx_1_1helpers_1_1ObjectPtrT.html">ObjectPtr</a> & </td> |
| <td class="mdname" nowrap> <em>defaultValue</em></td> |
| </tr> |
| <tr> |
| <td></td> |
| <td class="md">) </td> |
| <td class="md" colspan="2"><code> [static]</code></td> |
| </tr> |
| |
| </table> |
| </td> |
| </tr> |
| </table> |
| <table cellspacing=5 cellpadding=0 border=0> |
| <tr> |
| <td> |
| |
| </td> |
| <td> |
| |
| <p> |
| Instantiate an object given a class name. Check that the <code>className</code> is a subclass of <code>superClass</code>. If that test fails or the object could not be instantiated, then <code>defaultValue</code> is returned.<p> |
| <dl compact><dt><b>Parameters:</b></dt><dd> |
| <table border="0" cellspacing="2" cellpadding="0"> |
| <tr><td valign=top><em>className</em> </td><td>The fully qualified class name of the object to instantiate. </td></tr> |
| <tr><td valign=top><em>superClass</em> </td><td>The class to which the new object should belong. </td></tr> |
| <tr><td valign=top><em>defaultValue</em> </td><td>The object to return in case of non-fulfillment</td></tr> |
| </table> |
| </dl> |
| </td> |
| </tr> |
| </table> |
| <a class="anchor" name="e10" doxytag="log4cxx::helpers::OptionConverter::selectAndConfigure" ></a><p> |
| <table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> |
| <tr> |
| <td class="mdRow"> |
| <table cellpadding="0" cellspacing="0" border="0"> |
| <tr> |
| <td class="md" nowrap valign="top"> void selectAndConfigure </td> |
| <td class="md" valign="top">( </td> |
| <td class="md" nowrap valign="top">const String & </td> |
| <td class="mdname" nowrap> <em>configFileName</em>, </td> |
| </tr> |
| <tr> |
| <td></td> |
| <td></td> |
| <td class="md" nowrap>const String & </td> |
| <td class="mdname" nowrap> <em>clazz</em>, </td> |
| </tr> |
| <tr> |
| <td></td> |
| <td></td> |
| <td class="md" nowrap><a class="el" href="classlog4cxx_1_1helpers_1_1ObjectPtrT.html">spi::LoggerRepositoryPtr</a> & </td> |
| <td class="mdname" nowrap> <em>hierarchy</em></td> |
| </tr> |
| <tr> |
| <td></td> |
| <td class="md">) </td> |
| <td class="md" colspan="2"><code> [static]</code></td> |
| </tr> |
| |
| </table> |
| </td> |
| </tr> |
| </table> |
| <table cellspacing=5 cellpadding=0 border=0> |
| <tr> |
| <td> |
| |
| </td> |
| <td> |
| |
| <p> |
| Configure log4cxx given a configFileName.<p> |
| The configFileName must point to a file which will be interpreted by a new instance of a log4cxx configurator.<p> |
| All configurations steps are taken on the <code>hierarchy</code> passed as a parameter.<p> |
| <dl compact><dt><b>Parameters:</b></dt><dd> |
| <table border="0" cellspacing="2" cellpadding="0"> |
| <tr><td valign=top><em>configFileName</em> </td><td>The location of the configuration file. </td></tr> |
| <tr><td valign=top><em>clazz</em> </td><td>The classname, of the log4cxx configurator which will parse the file <code>configFileName</code>. This must be a subclass of Configurator, or null. If this value is null then a default configurator of <a class="el" href="classlog4cxx_1_1PropertyConfigurator.html">PropertyConfigurator</a> is used, unless the filename pointed to by <code>configFileName</code> ends in '.xml', in which case DOMConfigurator is used. </td></tr> |
| <tr><td valign=top><em>hierarchy</em> </td><td>The <a class="el" href="classlog4cxx_1_1Hierarchy.html">Hierarchy</a> to act on.</td></tr> |
| </table> |
| </dl> |
| </td> |
| </tr> |
| </table> |
| <a class="anchor" name="e6" doxytag="log4cxx::helpers::OptionConverter::substVars" ></a><p> |
| <table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> |
| <tr> |
| <td class="mdRow"> |
| <table cellpadding="0" cellspacing="0" border="0"> |
| <tr> |
| <td class="md" nowrap valign="top"> String substVars </td> |
| <td class="md" valign="top">( </td> |
| <td class="md" nowrap valign="top">const String & </td> |
| <td class="mdname" nowrap> <em>val</em>, </td> |
| </tr> |
| <tr> |
| <td></td> |
| <td></td> |
| <td class="md" nowrap>Properties & </td> |
| <td class="mdname" nowrap> <em>props</em></td> |
| </tr> |
| <tr> |
| <td></td> |
| <td class="md">) </td> |
| <td class="md" colspan="2"><code> [static]</code></td> |
| </tr> |
| |
| </table> |
| </td> |
| </tr> |
| </table> |
| <table cellspacing=5 cellpadding=0 border=0> |
| <tr> |
| <td> |
| |
| </td> |
| <td> |
| |
| <p> |
| Perform variable substitution in string <code>val</code> from the values of keys found in the system propeties.<p> |
| The variable substitution delimeters are <b>${</b> and <b>}</b>.<p> |
| For example, if the <a class="el" href="classlog4cxx_1_1helpers_1_1System.html">System</a> properties contains "key=value", then the call <pre><div> |
| String s = OptionConverter.substituteVars("Value of key is ${key}."); |
| </pre></div><p> |
| will set the variable <code>s</code> to "Value of key is value.".<p> |
| If no value could be found for the specified key, then the <code>props</code> parameter is searched, if the value could not be found there, then substitution defaults to the empty string.<p> |
| For example, if system propeties contains no value for the key "inexistentKey", then the call<p> |
| <pre><div> |
| String s = OptionConverter.subsVars("Value of inexistentKey is [${inexistentKey}]"); |
| </pre></div> will set <code>s</code> to "Value of inexistentKey is []"<p> |
| An <a class="el" href="classlog4cxx_1_1helpers_1_1IllegalArgumentException.html">IllegalArgumentException</a> is thrown if <code>val</code> contains a start delimeter "${" which is not balanced by a stop delimeter "}". <p> |
| <dl compact><dt><b>Parameters:</b></dt><dd> |
| <table border="0" cellspacing="2" cellpadding="0"> |
| <tr><td valign=top><em>val</em> </td><td>The string on which variable substitution is performed. </td></tr> |
| <tr><td valign=top><em>props</em> </td><td>The properties from which variable substitution is performed. </td></tr> |
| </table> |
| </dl> |
| <dl compact><dt><b>Exceptions:</b></dt><dd> |
| <table border="0" cellspacing="2" cellpadding="0"> |
| <tr><td valign=top><em>IllegalArgumentException</em> </td><td>if <code>val</code> is malformed. </td></tr> |
| </table> |
| </dl> |
| </td> |
| </tr> |
| </table> |
| <a class="anchor" name="e1" doxytag="log4cxx::helpers::OptionConverter::toBoolean" ></a><p> |
| <table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> |
| <tr> |
| <td class="mdRow"> |
| <table cellpadding="0" cellspacing="0" border="0"> |
| <tr> |
| <td class="md" nowrap valign="top"> bool toBoolean </td> |
| <td class="md" valign="top">( </td> |
| <td class="md" nowrap valign="top">const String & </td> |
| <td class="mdname" nowrap> <em>value</em>, </td> |
| </tr> |
| <tr> |
| <td></td> |
| <td></td> |
| <td class="md" nowrap>bool </td> |
| <td class="mdname" nowrap> <em>dEfault</em></td> |
| </tr> |
| <tr> |
| <td></td> |
| <td class="md">) </td> |
| <td class="md" colspan="2"><code> [static]</code></td> |
| </tr> |
| |
| </table> |
| </td> |
| </tr> |
| </table> |
| <table cellspacing=5 cellpadding=0 border=0> |
| <tr> |
| <td> |
| |
| </td> |
| <td> |
| |
| <p> |
| If <code>value</code> is "true", then <code>true</code> is returned. If <code>value</code> is "false", then <code>true</code> is returned. Otherwise, <code>default</code> is returned.<p> |
| Case of value is unimportant. </td> |
| </tr> |
| </table> |
| <hr>The documentation for this class was generated from the following files:<ul> |
| <li>optionconverter.h<li>optionconverter.cpp</ul> |
| |
| </td> |
| </tr> |
| |
| <!-- FOOTER --> |
| <tr><td colspan="2"> |
| <hr noshade="" size="1"/> |
| </td></tr> |
| <tr><td colspan="2"> |
| <div align="center"><font color="#525D76" size="-1"><em> |
| Copyright © 1999-2004, Apache Software Foundation |
| </em></font></div> |
| </td></tr> |
| </table> |
| <!-- END main table --> |
| </body> |
| </html> |
| <!-- end the processing --> |