dion 02/03/31 21:44:07
Added: docs/latka/xref/java/org/apache/commons/latka/validators
folder.gif file.gif XPathValidator.html
XPathHandler.html StatusCodeValidator.html
StatusCodeHandler.html RegexpValidator.html
RegexpHandler.html MaxRequestTimeValidator.html
MaxRequestTimeHandler.html index.html
GoldenFileValidator.html CookieValidator.html
CookieHandler.html ByteLengthValidator.html
ByteLengthHandler.html BaseValidator.html
Log:
New Maven generated site
Revision Changes Path
1.1 jakarta-commons/docs/latka/xref/java/org/apache/commons/latka/validators/folder.gif
<<Binary file>>
1.1 jakarta-commons/docs/latka/xref/java/org/apache/commons/latka/validators/file.gif
<<Binary file>>
1.1 jakarta-commons/docs/latka/xref/java/org/apache/commons/latka/validators/XPathValidator.html
Index: XPathValidator.html
===================================================================
<html>
<body bgcolor="white">
<pre>
<table bgcolor="#FFFFCC" cellpadding="0" cellspacing="0" border="0" width="100%"><a href="../../../../../../../apidocs/org/apache/commons/latka/validators/XPathValidator.html">View Javadoc</a></table>
<a name="1" href="#1">1</a>
<a name="2" href="#2">2</a> <font color="#329900"><i>/*</font></i>
<a name="3" href="#3">3</a> <font color="#329900"><i> * ====================================================================</font></i>
<a name="4" href="#4">4</a> <font color="#329900"><i> *</font></i>
<a name="5" href="#5">5</a> <font color="#329900"><i> * The Apache Software License, Version 1.1</font></i>
<a name="6" href="#6">6</a> <font color="#329900"><i> *</font></i>
<a name="7" href="#7">7</a> <font color="#329900"><i> * Copyright (c) 1999 The Apache Software Foundation. All rights </font></i>
<a name="8" href="#8">8</a> <font color="#329900"><i> * reserved.</font></i>
<a name="9" href="#9">9</a> <font color="#329900"><i> *</font></i>
<a name="10" href="#10">10</a> <font color="#329900"><i> * Redistribution and use in source and binary forms, with or without</font></i>
<a name="11" href="#11">11</a> <font color="#329900"><i> * modification, are permitted provided that the following conditions</font></i>
<a name="12" href="#12">12</a> <font color="#329900"><i> * are met:</font></i>
<a name="13" href="#13">13</a> <font color="#329900"><i> *</font></i>
<a name="14" href="#14">14</a> <font color="#329900"><i> * 1. Redistributions of source code must retain the above copyright</font></i>
<a name="15" href="#15">15</a> <font color="#329900"><i> * notice, this list of conditions and the following disclaimer. </font></i>
<a name="16" href="#16">16</a> <font color="#329900"><i> *</font></i>
<a name="17" href="#17">17</a> <font color="#329900"><i> * 2. Redistributions in binary form must reproduce the above copyright</font></i>
<a name="18" href="#18">18</a> <font color="#329900"><i> * notice, this list of conditions and the following disclaimer in</font></i>
<a name="19" href="#19">19</a> <font color="#329900"><i> * the documentation and/or other materials provided with the</font></i>
<a name="20" href="#20">20</a> <font color="#329900"><i> * distribution.</font></i>
<a name="21" href="#21">21</a> <font color="#329900"><i> *</font></i>
<a name="22" href="#22">22</a> <font color="#329900"><i> * 3. The end-user documentation included with the redistribution, if</font></i>
<a name="23" href="#23">23</a> <font color="#329900"><i> * any, must include the following acknowlegement: </font></i>
<a name="24" href="#24">24</a> <font color="#329900"><i> * "This product includes software developed by the </font></i>
<a name="25" href="#25">25</a> <font color="#329900"><i> * Apache Software Foundation (<a href="http://www.apache.org/" target="alexandria_uri">http://www.apache.org/</a>)."</font></i>
<a name="26" href="#26">26</a> <font color="#329900"><i> * Alternately, this acknowlegement may appear in the software itself,</font></i>
<a name="27" href="#27">27</a> <font color="#329900"><i> * if and wherever such third-party acknowlegements normally appear.</font></i>
<a name="28" href="#28">28</a> <font color="#329900"><i> *</font></i>
<a name="29" href="#29">29</a> <font color="#329900"><i> * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software</font></i>
<a name="30" href="#30">30</a> <font color="#329900"><i> * Foundation" must not be used to endorse or promote products derived</font></i>
<a name="31" href="#31">31</a> <font color="#329900"><i> * from this software without prior written permission. For written </font></i>
<a name="32" href="#32">32</a> <font color="#329900"><i> * permission, please contact apache@apache.org.</font></i>
<a name="33" href="#33">33</a> <font color="#329900"><i> *</font></i>
<a name="34" href="#34">34</a> <font color="#329900"><i> * 5. Products derived from this software may not be called "Apache"</font></i>
<a name="35" href="#35">35</a> <font color="#329900"><i> * nor may "Apache" appear in their names without prior written</font></i>
<a name="36" href="#36">36</a> <font color="#329900"><i> * permission of the Apache Group.</font></i>
<a name="37" href="#37">37</a> <font color="#329900"><i> *</font></i>
<a name="38" href="#38">38</a> <font color="#329900"><i> * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED</font></i>
<a name="39" href="#39">39</a> <font color="#329900"><i> * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES</font></i>
<a name="40" href="#40">40</a> <font color="#329900"><i> * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE</font></i>
<a name="41" href="#41">41</a> <font color="#329900"><i> * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR</font></i>
<a name="42" href="#42">42</a> <font color="#329900"><i> * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,</font></i>
<a name="43" href="#43">43</a> <font color="#329900"><i> * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT</font></i>
<a name="44" href="#44">44</a> <font color="#329900"><i> * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF</font></i>
<a name="45" href="#45">45</a> <font color="#329900"><i> * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND</font></i>
<a name="46" href="#46">46</a> <font color="#329900"><i> * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,</font></i>
<a name="47" href="#47">47</a> <font color="#329900"><i> * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT</font></i>
<a name="48" href="#48">48</a> <font color="#329900"><i> * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF</font></i>
<a name="49" href="#49">49</a> <font color="#329900"><i> * SUCH DAMAGE.</font></i>
<a name="50" href="#50">50</a> <font color="#329900"><i> * ====================================================================</font></i>
<a name="51" href="#51">51</a> <font color="#329900"><i> *</font></i>
<a name="52" href="#52">52</a> <font color="#329900"><i> * This software consists of voluntary contributions made by many</font></i>
<a name="53" href="#53">53</a> <font color="#329900"><i> * individuals on behalf of the Apache Software Foundation. For more</font></i>
<a name="54" href="#54">54</a> <font color="#329900"><i> * information on the Apache Software Foundation, please see</font></i>
<a name="55" href="#55">55</a> <font color="#329900"><i> * <<a href="http://www.apache.org/>" target="alexandria_uri">http://www.apache.org/></a>;.</font></i>
<a name="56" href="#56">56</a> <font color="#329900"><i> *</font></i>
<a name="57" href="#57">57</a> <font color="#329900"><i> * [Additional notices, if required by prior licensing conditions]</font></i>
<a name="58" href="#58">58</a> <font color="#329900"><i> *</font></i>
<a name="59" href="#59">59</a> <font color="#329900"><i> */</font></i>
<a name="60" href="#60">60</a> <b>package</b> <a href="../../../../../org/apache/commons/latka/validators/index.html">org.apache.commons.latka.validators</a>;
<a name="61" href="#61">61</a>
<a name="62" href="#62">62</a> <b>import</b> <a href="../../../../../org/apache/commons/latka/index.html">org.apache.commons.latka</a>.<a href="../../../../../org/apache/commons/latka/Validator.html">Validator</a>;
<a name="63" href="#63">63</a> <b>import</b> <a href="../../../../../org/apache/commons/latka/index.html">org.apache.commons.latka</a>.<a href="../../../../../org/apache/commons/latka/ValidationException.html">ValidationException</a>;
<a name="64" href="#64">64</a>
<a name="65" href="#65">65</a> <b>import</b> <a href="../../../../../org/apache/commons/latka/http/index.html">org.apache.commons.latka.http</a>.<a href="../../../../../org/apache/commons/latka/http/Response.html">Response</a>;
<a name="66" href="#66">66</a>
<a name="67" href="#67">67</a> <b>import</b> org.jdom.Document;
<a name="68" href="#68">68</a> <b>import</b> org.jdom.Element;
<a name="69" href="#69">69</a> <b>import</b> org.jdom.JDOMException;
<a name="70" href="#70">70</a> <b>import</b> org.jdom.input.SAXBuilder;
<a name="71" href="#71">71</a> <b>import</b> org.jaxen.jdom.XPath;
<a name="72" href="#72">72</a> <b>import</b> org.jaxen.JaxenException;
<a name="73" href="#73">73</a>
<a name="74" href="#74">74</a> <font color="#AA0000"><i>/**<font color="#AA0000"><i>*</font></i></font></i>
<a name="75" href="#75">75</a> <font color="#AA0000"><i> * An XPath validator.</font></i>
<a name="76" href="#76">76</a> <font color="#AA0000"><i> *</font></i>
<a name="77" href="#77">77</a> <font color="#AA0000"><i> * <p>Use is of the form:</p></font></i>
<a name="78" href="#78">78</a> <font color="#AA0000"><i> * <p><xpath select="..." [ value="..." ] [ cond="true | false" ] /></p></font></i>
<a name="79" href="#79">79</a> <font color="#AA0000"><i> * <p>Where :</p></font></i>
<a name="80" href="#80">80</a> <font color="#AA0000"><i> * <ul></font></i>
<a name="81" href="#81">81</a> <font color="#AA0000"><i> * <li><code>select</code> is an XPath expression, designed to match a node in</font></i>
<a name="82" href="#82">82</a> <font color="#AA0000"><i> * the XML body of the response.</li></font></i>
<a name="83" href="#83">83</a> <font color="#AA0000"><i> * <li><code>value</code> is an option value which the string value of the</font></i>
<a name="84" href="#84">84</a> <font color="#AA0000"><i> * selected node should match.</li></font></i>
<a name="85" href="#85">85</a> <font color="#AA0000"><i> * <li><code>cond</code> is an optional boolean value, indicating</font></i>
<a name="86" href="#86">86</a> <font color="#AA0000"><i> * whether the test logic is to be inverted. Defaults to</font></i>
<a name="87" href="#87">87</a> <font color="#AA0000"><i> * <code>true</code>.</li></font></i>
<a name="88" href="#88">88</a> <font color="#AA0000"><i> * </ul></font></i>
<a name="89" href="#89">89</a> <font color="#AA0000"><i> *</font></i>
<a name="90" href="#90">90</a> <font color="#AA0000"><i> * </p></font></i>
<a name="91" href="#91">91</a> <font color="#AA0000"><i> * <p></font></i>
<a name="92" href="#92">92</a> <font color="#AA0000"><i> * If the user has specified a {@link #setValue value}, then the XPath</font></i>
<a name="93" href="#93">93</a> <font color="#AA0000"><i> * expression is expected to evaluate to a text or attribute node (or other</font></i>
<a name="94" href="#94">94</a> <font color="#AA0000"><i> * textual 'leaf' nodes), in which case the selected value must match that</font></i>
<a name="95" href="#95">95</a> <font color="#AA0000"><i> * specified.</font></i>
<a name="96" href="#96">96</a> <font color="#AA0000"><i> * </p></font></i>
<a name="97" href="#97">97</a> <font color="#AA0000"><i> * <p></font></i>
<a name="98" href="#98">98</a> <font color="#AA0000"><i> * If no value is specified, then the XPath expression will be used to check for</font></i>
<a name="99" href="#99">99</a> <font color="#AA0000"><i> * the <em>existence</em> of a node.</font></i>
<a name="100" href="#100">100</a> <font color="#AA0000"><i> * </p></font></i>
<a name="101" href="#101">101</a> <font color="#AA0000"><i> * <p></font></i>
<a name="102" href="#102">102</a> <font color="#AA0000"><i> * If the XPath expression evaluates to a boolean condition (eg</font></i>
<a name="103" href="#103">103</a> <font color="#AA0000"><i> * <xpath select="foo/bar='baz'"/>), then the condition will be evaluated and will</font></i>
<a name="104" href="#104">104</a> <font color="#AA0000"><i> * result in the test passing or failing. Equivalently, an expression may be</font></i>
<a name="105" href="#105">105</a> <font color="#AA0000"><i> * specified, and <code>value</code> used to require a specific value (eg</font></i>
<a name="106" href="#106">106</a> <font color="#AA0000"><i> * <xpath select="/foo/bar" value="baz"/>).</font></i>
<a name="107" href="#107">107</a> <font color="#AA0000"><i> * </p></font></i>
<a name="108" href="#108">108</a> <font color="#AA0000"><i> * <p></font></i>
<a name="109" href="#109">109</a> <font color="#AA0000"><i> * Finally, setting <code>cond="false"</code> negates the sense of the</font></i>
<a name="110" href="#110">110</a> <font color="#AA0000"><i> * test, allowing one to test for the <em>nonexistence</em> or</font></i>
<a name="111" href="#111">111</a> <font color="#AA0000"><i> * <em>inequality</em> of nodes and values.</font></i>
<a name="112" href="#112">112</a> <font color="#AA0000"><i> * </p></font></i>
<a name="113" href="#113">113</a> <font color="#AA0000"><i> *</font></i>
<a name="114" href="#114">114</a> <font color="#AA0000"><i> * @author <a href="<a href="mailto:jefft@apache.org" target="alexandria_uri">mailto:jefft@apache.org</a>">Jeff Turner</a></font></i>
<a name="115" href="#115">115</a> <font color="#AA0000"><i> * @author dIon Gillard</font></i>
<a name="116" href="#116">116</a> <font color="#AA0000"><i> * @since 6 January, 2001</font></i>
<a name="117" href="#117">117</a> <font color="#AA0000"><i> * @version $Id: XPathValidator.html,v 1.1 2002/04/01 05:44:07 dion Exp $</font></i>
<a name="118" href="#118">118</a> <font color="#AA0000"><i> */</font></i>
<a name="119" href="#119">119</a> <b>public</b> <b>class</b> <a href="../../../../../org/apache/commons/latka/validators/XPathValidator.html">XPathValidator</a> <b>extends</b> <a href="../../../../../org/apache/commons/latka/validators/BaseValidator.html">BaseValidator</a> implements <a href="../../../../../org/apache/commons/latka/Validator.html">Validator</a> {
<a name="120" href="#120">120</a>
<a name="121" href="#121">121</a> <font color="#329900"><i>// General notes:</font></i>
<a name="122" href="#122">122</a> <font color="#329900"><i>// - It started out simple, honest.. =)</font></i>
<a name="123" href="#123">123</a> <font color="#329900"><i>// - We really need to separate out the negation logic into a separate <not></font></i>
<a name="124" href="#124">124</a> <font color="#329900"><i>// tag. It's silly having xpath, regexp and whathaveyou all doing their own</font></i>
<a name="125" href="#125">125</a> <font color="#329900"><i>// negation tests..</font></i>
<a name="126" href="#126">126</a> <font color="#329900"><i>// - Need some unit tests, with a mock object for the Response.</font></i>
<a name="127" href="#127">127</a>
<a name="128" href="#128">128</a> <font color="#329900"><i>// --------------------------------------------------------------- Attributes</font></i>
<a name="129" href="#129">129</a>
<a name="130" href="#130">130</a> <b>protected</b> String _select = <b>null</b>;
<a name="131" href="#131">131</a> <b>protected</b> <b>boolean</b> _cond = <b>true</b>;
<a name="132" href="#132">132</a> <b>protected</b> String _value = <b>null</b>;
<a name="133" href="#133">133</a>
<a name="134" href="#134">134</a> <b>protected</b> <b>static</b> <b>final</b> String TRUE_MESSAGE = <font color="#000099">"EXPECTED TO MATCH XPATH: "</font>;
<a name="135" href="#135">135</a> <b>protected</b> <b>static</b> <b>final</b> String FALSE_MESSAGE = <font color="#000099">"DID NOT EXPECT TO MATCH XPATH: "</font>;
<a name="136" href="#136">136</a>
<a name="137" href="#137">137</a> <font color="#329900"><i>// ------------------------------------------------------------- Constructors</font></i>
<a name="138" href="#138">138</a>
<a name="139" href="#139">139</a> <b>public</b> <a href="../../../../../org/apache/commons/latka/validators/XPathValidator.html">XPathValidator</a>() {
<a name="140" href="#140">140</a> <b>this</b>(<b>null</b>,<b>null</b>,<b>true</b>,<b>null</b>);
<a name="141" href="#141">141</a> }
<a name="142" href="#142">142</a>
<a name="143" href="#143">143</a> <b>public</b> <a href="../../../../../org/apache/commons/latka/validators/XPathValidator.html">XPathValidator</a>(String label) {
<a name="144" href="#144">144</a> <b>this</b>(label,<b>null</b>,<b>true</b>,<b>null</b>);
<a name="145" href="#145">145</a> }
<a name="146" href="#146">146</a>
<a name="147" href="#147">147</a> <b>public</b> <a href="../../../../../org/apache/commons/latka/validators/XPathValidator.html">XPathValidator</a>(String label, String select, <b>boolean</b> cond, String value) {
<a name="148" href="#148">148</a> <b>super</b>(label);
<a name="149" href="#149">149</a> _select = select;
<a name="150" href="#150">150</a> _cond = cond;
<a name="151" href="#151">151</a> _value = value;
<a name="152" href="#152">152</a> }
<a name="153" href="#153">153</a>
<a name="154" href="#154">154</a> <font color="#329900"><i>// ------------------------------------------------------------------ Public Methods</font></i>
<a name="155" href="#155">155</a>
<a name="156" href="#156">156</a> <b>public</b> <b>void</b> setSelect(String select) {
<a name="157" href="#157">157</a> _select = select;
<a name="158" href="#158">158</a> }
<a name="159" href="#159">159</a>
<a name="160" href="#160">160</a> <b>public</b> <b>void</b> setCondition(<b>boolean</b> cond) {
<a name="161" href="#161">161</a> _cond = cond;
<a name="162" href="#162">162</a> }
<a name="163" href="#163">163</a>
<a name="164" href="#164">164</a> <b>public</b> <b>void</b> setValue(String value) {
<a name="165" href="#165">165</a> _value = value;
<a name="166" href="#166">166</a> }
<a name="167" href="#167">167</a>
<a name="168" href="#168">168</a> <b>public</b> <b>void</b> validate(<a href="../../../../../org/apache/commons/latka/http/Response.html">Response</a> response)
<a name="169" href="#169">169</a> throws <a href="../../../../../org/apache/commons/latka/ValidationException.html">ValidationException</a> {
<a name="170" href="#170">170</a>
<a name="171" href="#171">171</a> XPath xpath = getXPath(_select); <font color="#329900"><i>// compile the XPath expression</font></i>
<a name="172" href="#172">172</a> Document doc = getDocument(response); <font color="#329900"><i>// retrieve the XML Document to process</font></i>
<a name="173" href="#173">173</a> Object selected = getSelectedNode(xpath, doc); <font color="#329900"><i>// Apply the XPath to retrieve a node</font></i>
<a name="174" href="#174">174</a>
<a name="175" href="#175">175</a>
<a name="176" href="#176">176</a> <font color="#329900"><i>// Now the fun begins, where we see if our selected node meets the criteria.</font></i>
<a name="177" href="#177">177</a> <font color="#329900"><i>// There are three factors:</font></i>
<a name="178" href="#178">178</a> <font color="#329900"><i>// </font></i>
<a name="179" href="#179">179</a> <font color="#329900"><i>// 1) What type of object did the XPath expression return?</font></i>
<a name="180" href="#180">180</a> <font color="#329900"><i>// 2) If _value is specified, ie if we're testing for _value_ or _existence_</font></i>
<a name="181" href="#181">181</a> <font color="#329900"><i>// 3) If _cond is true/false, ie do we WANT the value to match/node to exist?</font></i>
<a name="182" href="#182">182</a>
<a name="183" href="#183">183</a>
<a name="184" href="#184">184</a> <b>if</b> (selected instanceof Boolean) {
<a name="185" href="#185">185</a> <font color="#329900"><i>// Eg, we had an expression /foo = 'bar'</font></i>
<a name="186" href="#186">186</a> _log.debug(<font color="#000099">"Boolean XPath expression evaluated to "</font>+selected);
<a name="187" href="#187">187</a> <b>if</b> (_value != <b>null</b>) {
<a name="188" href="#188">188</a> _log.warn(<font color="#000099">"Ignoring unused value '"</font>+_value+<font color="#000099">"'."</font>);
<a name="189" href="#189">189</a> }
<a name="190" href="#190">190</a> <b>boolean</b> matched = ((Boolean)selected).<b>boolean</b>Value();
<a name="191" href="#191">191</a> <b>if</b> (_cond != matched) {
<a name="192" href="#192">192</a> fail(<font color="#000099">"Boolean XPath '"</font>+_select+<font color="#000099">"' didn't match."</font>);
<a name="193" href="#193">193</a> }
<a name="194" href="#194">194</a> } <b>else</b> <b>if</b> (selected instanceof String) {
<a name="195" href="#195">195</a> _log.debug(<font color="#000099">"XPath selected string '"</font>+selected+<font color="#000099">"'."</font>);
<a name="196" href="#196">196</a> <b>if</b> (_value != <b>null</b>) {
<a name="197" href="#197">197</a> <b>boolean</b> matched = selected.equals(_value);
<a name="198" href="#198">198</a> <b>if</b> (_cond != matched) {
<a name="199" href="#199">199</a> StringBuffer buf = <b>new</b> StringBuffer();
<a name="200" href="#200">200</a> <b>if</b> (_cond == <b>true</b>) {
<a name="201" href="#201">201</a> buf.append(TRUE_MESSAGE);
<a name="202" href="#202">202</a> } <b>else</b> {
<a name="203" href="#203">203</a> buf.append(FALSE_MESSAGE);
<a name="204" href="#204">204</a> }
<a name="205" href="#205">205</a> buf.append(_select);
<a name="206" href="#206">206</a> fail(buf.toString());
<a name="207" href="#207">207</a> }
<a name="208" href="#208">208</a> } <b>else</b> {
<a name="209" href="#209">209</a> <font color="#329900"><i>// otherwise we only test if the node is meant to exist</font></i>
<a name="210" href="#210">210</a> <b>if</b> (!_cond) {
<a name="211" href="#211">211</a> fail(<font color="#000099">"XPath '"</font>+_select+<font color="#000099">"' selected string '"</font>+selected+
<a name="212" href="#212">212</a> <font color="#000099">"' when specified not to."</font>);
<a name="213" href="#213">213</a> }
<a name="214" href="#214">214</a> }
<a name="215" href="#215">215</a> } <b>else</b> <b>if</b> (selected instanceof Element) {
<a name="216" href="#216">216</a> <b>if</b> (_log.isDebugEnabled()) {
<a name="217" href="#217">217</a> _log.debug(<font color="#000099">"XPath matched element: "</font>);
<a name="218" href="#218">218</a> _log.debug(printElement((Element)selected));
<a name="219" href="#219">219</a> }
<a name="220" href="#220">220</a> <b>if</b> (_value != <b>null</b>) {
<a name="221" href="#221">221</a> _log.warn(<font color="#000099">"Ignoring unused value '"</font>+_value+<font color="#000099">"'."</font>);
<a name="222" href="#222">222</a> }
<a name="223" href="#223">223</a> <b>if</b> (!_cond) {
<a name="224" href="#224">224</a> fail(<font color="#000099">"XPath '"</font>+_select+<font color="#000099">"' selected element '"</font>+selected+
<a name="225" href="#225">225</a> <font color="#000099">"' when specified not to."</font>);
<a name="226" href="#226">226</a> }
<a name="227" href="#227">227</a> } <b>else</b> {
<a name="228" href="#228">228</a> <font color="#329900"><i>// Otherwise Jaxen is returning something odd</font></i>
<a name="229" href="#229">229</a> <b>if</b> (_value != <b>null</b>) {
<a name="230" href="#230">230</a> <font color="#329900"><i>// Hope that .equals() does a sensible comparison</font></i>
<a name="231" href="#231">231</a> <b>boolean</b> matched = selected.equals(_value);
<a name="232" href="#232">232</a> <b>if</b> (_cond != matched) {
<a name="233" href="#233">233</a> fail(<font color="#000099">"XPath expression '"</font>+_value+<font color="#000099">"' returned '"</font>+selected+
<a name="234" href="#234">234</a> <font color="#000099">"' of unknown type "</font>+selected.getClass().getName()+
<a name="235" href="#235">235</a> <font color="#000099">". This did "</font>+(_cond?<font color="#000099">"not "</font>:<font color="#000099">""</font>)+<font color="#000099">"match the specified value '"</font>+_value+<font color="#000099">"'."</font>
<a name="236" href="#236">236</a> );
<a name="237" href="#237">237</a> }
<a name="238" href="#238">238</a> } <b>else</b> {
<a name="239" href="#239">239</a> <font color="#329900"><i>// only test if the node (whatever it is) is meant to exist</font></i>
<a name="240" href="#240">240</a> <b>if</b> (!_cond) {
<a name="241" href="#241">241</a> fail(<font color="#000099">"XPath '"</font>+_select+<font color="#000099">"' selected node '"</font>+selected+
<a name="242" href="#242">242</a> <font color="#000099">"' when specified not to."</font>);
<a name="243" href="#243">243</a> }
<a name="244" href="#244">244</a> _log.warn(<font color="#000099">"Selected unknown type "</font>+selected.getClass().getName());
<a name="245" href="#245">245</a> }
<a name="246" href="#246">246</a> }
<a name="247" href="#247">247</a> }
<a name="248" href="#248">248</a>
<a name="249" href="#249">249</a> <font color="#329900"><i>// ------------------------------------------------------------------ Private Methods</font></i>
<a name="250" href="#250">250</a>
<a name="251" href="#251">251</a> <font color="#AA0000"><i>/**<font color="#AA0000"><i>*</font></i></font></i>
<a name="252" href="#252">252</a> <font color="#AA0000"><i> * Creates a Jaxen <code>XPath</code> for a given XPath expression.</font></i>
<a name="253" href="#253">253</a> <font color="#AA0000"><i> * @param xpathExpr The XPath expression</font></i>
<a name="254" href="#254">254</a> <font color="#AA0000"><i> * @return A non-null Jaxen <code>XPath</code> object.</font></i>
<a name="255" href="#255">255</a> <font color="#AA0000"><i> * @throws ValidationException if <code>xpathExpr</code> was invalid.</font></i>
<a name="256" href="#256">256</a> <font color="#AA0000"><i> */</font></i>
<a name="257" href="#257">257</a> <b>private</b> XPath getXPath(<b>final</b> String xpathExpr)
<a name="258" href="#258">258</a> throws <a href="../../../../../org/apache/commons/latka/ValidationException.html">ValidationException</a>
<a name="259" href="#259">259</a> {
<a name="260" href="#260">260</a> XPath xpath = <b>null</b>;
<a name="261" href="#261">261</a> <b>try</b> {
<a name="262" href="#262">262</a> xpath = <b>new</b> XPath(xpathExpr);
<a name="263" href="#263">263</a> } <b>catch</b> (JaxenException e) {
<a name="264" href="#264">264</a> fail(<font color="#000099">"Couldn't compile XPath xpathExpr "</font>+xpathExpr+<font color="#000099">": "</font>+e.toString());
<a name="265" href="#265">265</a> }
<a name="266" href="#266">266</a>
<a name="267" href="#267">267</a> <b>if</b> (xpath == <b>null</b>) { <font color="#329900"><i>// this should never happen</font></i>
<a name="268" href="#268">268</a> fail(<font color="#000099">"Null compiled XPath object"</font>);
<a name="269" href="#269">269</a> }
<a name="270" href="#270">270</a>
<a name="271" href="#271">271</a> <b>if</b> (_log.isDebugEnabled()) {
<a name="272" href="#272">272</a> _log.debug(<font color="#000099">"Using XPath expression: "</font>+xpathExpr);
<a name="273" href="#273">273</a> }
<a name="274" href="#274">274</a> <b>return</b> xpath;
<a name="275" href="#275">275</a> }
<a name="276" href="#276">276</a>
<a name="277" href="#277">277</a> <font color="#AA0000"><i>/**<font color="#AA0000"><i>*</font></i></font></i>
<a name="278" href="#278">278</a> <font color="#AA0000"><i> * Creates a <code>Document</code> from the Response.</font></i>
<a name="279" href="#279">279</a> <font color="#AA0000"><i> * @param response The (usu. HTTP) Reponse object presumably containing an XML</font></i>
<a name="280" href="#280">280</a> <font color="#AA0000"><i> * response body.</font></i>
<a name="281" href="#281">281</a> <font color="#AA0000"><i> * @return A non-null <code>Document</code> representing the response body.</font></i>
<a name="282" href="#282">282</a> <font color="#AA0000"><i> * @throws ValidationException if the Response object's body did not contain</font></i>
<a name="283" href="#283">283</a> <font color="#AA0000"><i> * well-formed XML.</font></i>
<a name="284" href="#284">284</a> <font color="#AA0000"><i> */</font></i>
<a name="285" href="#285">285</a> <b>private</b> Document getDocument(<a href="../../../../../org/apache/commons/latka/http/Response.html">Response</a> response)
<a name="286" href="#286">286</a> throws <a href="../../../../../org/apache/commons/latka/ValidationException.html">ValidationException</a>
<a name="287" href="#287">287</a> {
<a name="288" href="#288">288</a> Document doc = <b>null</b>;
<a name="289" href="#289">289</a> SAXBuilder builder = <b>new</b> SAXBuilder();
<a name="290" href="#290">290</a> <b>try</b> {
<a name="291" href="#291">291</a> doc = builder.build(response.getStream());
<a name="292" href="#292">292</a> } <b>catch</b> (JDOMException e) {
<a name="293" href="#293">293</a> fail(e.toString());
<a name="294" href="#294">294</a> }
<a name="295" href="#295">295</a> <b>if</b> (doc == <b>null</b>) { <font color="#329900"><i>// this should never happen</font></i>
<a name="296" href="#296">296</a> fail(<font color="#000099">"Null document"</font>);
<a name="297" href="#297">297</a> }
<a name="298" href="#298">298</a> <b>if</b> (_log.isDebugEnabled()) {
<a name="299" href="#299">299</a> _log.debug(<font color="#000099">"Processing doc: "</font>+printDoc(doc));
<a name="300" href="#300">300</a> }
<a name="301" href="#301">301</a> <b>return</b> doc;
<a name="302" href="#302">302</a> }
<a name="303" href="#303">303</a>
<a name="304" href="#304">304</a> <font color="#AA0000"><i>/**<font color="#AA0000"><i>*</font></i></font></i>
<a name="305" href="#305">305</a> <font color="#AA0000"><i> * Apply a compiled XPath expression to an XML Document, and return the</font></i>
<a name="306" href="#306">306</a> <font color="#AA0000"><i> * selected node. </font></i>
<a name="307" href="#307">307</a> <font color="#AA0000"><i> * @param xpath The compiled Jaxen <code>XPath</code> object</font></i>
<a name="308" href="#308">308</a> <font color="#AA0000"><i> * @param doc The <code>Document</code> object containing the XML.</font></i>
<a name="309" href="#309">309</a> <font color="#AA0000"><i> * @return A non-null object returned from Jaxen. This may be:</font></i>
<a name="310" href="#310">310</a> <font color="#AA0000"><i> * <ul></font></i>
<a name="311" href="#311">311</a> <font color="#AA0000"><i> * <li>A String, if the expression selected an element with a text node child</li></font></i>
<a name="312" href="#312">312</a> <font color="#AA0000"><i> * <li>An <code>Element</code></li></font></i>
<a name="313" href="#313">313</a> <font color="#AA0000"><i> * <li>A <code>java.lang.Boolean</code>, if the XPath expression is a</font></i>
<a name="314" href="#314">314</a> <font color="#AA0000"><i> * statement (eg /foo/bar='content')</li></font></i>
<a name="315" href="#315">315</a> <font color="#AA0000"><i> * <li>Anything else the Jaxen author deemed useful; ie don't assume anything</li></font></i>
<a name="316" href="#316">316</a> <font color="#AA0000"><i> * </ul></font></i>
<a name="317" href="#317">317</a> <font color="#AA0000"><i> */</font></i>
<a name="318" href="#318">318</a> <b>private</b> Object getSelectedNode(XPath xpath, Document doc)
<a name="319" href="#319">319</a> throws <a href="../../../../../org/apache/commons/latka/ValidationException.html">ValidationException</a>
<a name="320" href="#320">320</a> {
<a name="321" href="#321">321</a> Object selected = <b>null</b>;
<a name="322" href="#322">322</a> <b>try</b> {
<a name="323" href="#323">323</a> selected = xpath.selectSingleNode(doc);
<a name="324" href="#324">324</a> } <b>catch</b> (JaxenException e) {
<a name="325" href="#325">325</a> fail(<font color="#000099">"XPath expression '"</font>+_select+<font color="#000099">"' didn't match any node. "</font>+e.toString());
<a name="326" href="#326">326</a> }
<a name="327" href="#327">327</a> <b>if</b> (selected == <b>null</b>) {
<a name="328" href="#328">328</a> fail(<font color="#000099">"Couldn't find node '"</font>+_select+<font color="#000099">"' in document"</font>);
<a name="329" href="#329">329</a> }
<a name="330" href="#330">330</a>
<a name="331" href="#331">331</a> <b>return</b> selected;
<a name="332" href="#332">332</a> }
<a name="333" href="#333">333</a>
<a name="334" href="#334">334</a> <font color="#AA0000"><i>/**<font color="#AA0000"><i>*</font></i></font></i>
<a name="335" href="#335">335</a> <font color="#AA0000"><i> * Utility method for returning an XML rendition of a <code>Document</code>.</font></i>
<a name="336" href="#336">336</a> <font color="#AA0000"><i> * @param doc The Document to print</font></i>
<a name="337" href="#337">337</a> <font color="#AA0000"><i> * @return A String of XML representing the document.</font></i>
<a name="338" href="#338">338</a> <font color="#AA0000"><i> */</font></i>
<a name="339" href="#339">339</a> <b>private</b> String printDoc(<b>final</b> Document doc) {
<a name="340" href="#340">340</a> java.io.StringWriter sw = <b>new</b> java.io.StringWriter();
<a name="341" href="#341">341</a> <b>try</b> {
<a name="342" href="#342">342</a> <b>new</b> org.jdom.output.XMLOutputter().output(doc, sw);
<a name="343" href="#343">343</a> } <b>catch</b> (java.io.IOException ioe) {
<a name="344" href="#344">344</a> _log.error(<font color="#000099">"Could not print XML document."</font>, ioe);
<a name="345" href="#345">345</a> }
<a name="346" href="#346">346</a> <b>return</b> sw.toString();
<a name="347" href="#347">347</a> }
<a name="348" href="#348">348</a>
<a name="349" href="#349">349</a> <font color="#AA0000"><i>/**<font color="#AA0000"><i>*</font></i></font></i>
<a name="350" href="#350">350</a> <font color="#AA0000"><i> * Utility method for returning an XML rendition of a <code>Element</code>.</font></i>
<a name="351" href="#351">351</a> <font color="#AA0000"><i> * @param elem an <code>Element</code> to print.</font></i>
<a name="352" href="#352">352</a> <font color="#AA0000"><i> * @return A String of XML representing the element.</font></i>
<a name="353" href="#353">353</a> <font color="#AA0000"><i> */</font></i>
<a name="354" href="#354">354</a> <b>private</b> String printElement(<b>final</b> Element elem) {
<a name="355" href="#355">355</a> java.io.StringWriter sw = <b>new</b> java.io.StringWriter();
<a name="356" href="#356">356</a> Element clone = (Element)((Element)elem).clone();
<a name="357" href="#357">357</a> org.jdom.output.XMLOutputter xmlOut = <b>new</b> org.jdom.output.XMLOutputter();
<a name="358" href="#358">358</a> <b>try</b> {
<a name="359" href="#359">359</a> xmlOut.output(<b>new</b> org.jdom.Document(clone), sw);
<a name="360" href="#360">360</a> } <b>catch</b> (java.io.IOException ioe) {
<a name="361" href="#361">361</a> _log.error(<font color="#000099">"Could not print XML element."</font>, ioe);
<a name="362" href="#362">362</a> }
<a name="363" href="#363">363</a> <b>return</b> sw.toString();
<a name="364" href="#364">364</a> }
<a name="365" href="#365">365</a> }
</pre>
<hr><center>This page automatically generated by Maven</center></body>
</html>
1.1 jakarta-commons/docs/latka/xref/java/org/apache/commons/latka/validators/XPathHandler.html
Index: XPathHandler.html
===================================================================
<html>
<body bgcolor="white">
<pre>
<table bgcolor="#FFFFCC" cellpadding="0" cellspacing="0" border="0" width="100%"><a href="../../../../../../../apidocs/org/apache/commons/latka/validators/XPathHandler.html">View Javadoc</a></table>
<a name="1" href="#1">1</a> <font color="#329900"><i>/*</font></i>
<a name="2" href="#2">2</a> <font color="#329900"><i> * ====================================================================</font></i>
<a name="3" href="#3">3</a> <font color="#329900"><i> *</font></i>
<a name="4" href="#4">4</a> <font color="#329900"><i> * The Apache Software License, Version 1.1</font></i>
<a name="5" href="#5">5</a> <font color="#329900"><i> *</font></i>
<a name="6" href="#6">6</a> <font color="#329900"><i> * Copyright (c) 1999 The Apache Software Foundation. All rights </font></i>
<a name="7" href="#7">7</a> <font color="#329900"><i> * reserved.</font></i>
<a name="8" href="#8">8</a> <font color="#329900"><i> *</font></i>
<a name="9" href="#9">9</a> <font color="#329900"><i> * Redistribution and use in source and binary forms, with or without</font></i>
<a name="10" href="#10">10</a> <font color="#329900"><i> * modification, are permitted provided that the following conditions</font></i>
<a name="11" href="#11">11</a> <font color="#329900"><i> * are met:</font></i>
<a name="12" href="#12">12</a> <font color="#329900"><i> *</font></i>
<a name="13" href="#13">13</a> <font color="#329900"><i> * 1. Redistributions of source code must retain the above copyright</font></i>
<a name="14" href="#14">14</a> <font color="#329900"><i> * notice, this list of conditions and the following disclaimer. </font></i>
<a name="15" href="#15">15</a> <font color="#329900"><i> *</font></i>
<a name="16" href="#16">16</a> <font color="#329900"><i> * 2. Redistributions in binary form must reproduce the above copyright</font></i>
<a name="17" href="#17">17</a> <font color="#329900"><i> * notice, this list of conditions and the following disclaimer in</font></i>
<a name="18" href="#18">18</a> <font color="#329900"><i> * the documentation and/or other materials provided with the</font></i>
<a name="19" href="#19">19</a> <font color="#329900"><i> * distribution.</font></i>
<a name="20" href="#20">20</a> <font color="#329900"><i> *</font></i>
<a name="21" href="#21">21</a> <font color="#329900"><i> * 3. The end-user documentation included with the redistribution, if</font></i>
<a name="22" href="#22">22</a> <font color="#329900"><i> * any, must include the following acknowlegement: </font></i>
<a name="23" href="#23">23</a> <font color="#329900"><i> * "This product includes software developed by the </font></i>
<a name="24" href="#24">24</a> <font color="#329900"><i> * Apache Software Foundation (<a href="http://www.apache.org/" target="alexandria_uri">http://www.apache.org/</a>)."</font></i>
<a name="25" href="#25">25</a> <font color="#329900"><i> * Alternately, this acknowlegement may appear in the software itself,</font></i>
<a name="26" href="#26">26</a> <font color="#329900"><i> * if and wherever such third-party acknowlegements normally appear.</font></i>
<a name="27" href="#27">27</a> <font color="#329900"><i> *</font></i>
<a name="28" href="#28">28</a> <font color="#329900"><i> * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software</font></i>
<a name="29" href="#29">29</a> <font color="#329900"><i> * Foundation" must not be used to endorse or promote products derived</font></i>
<a name="30" href="#30">30</a> <font color="#329900"><i> * from this software without prior written permission. For written </font></i>
<a name="31" href="#31">31</a> <font color="#329900"><i> * permission, please contact apache@apache.org.</font></i>
<a name="32" href="#32">32</a> <font color="#329900"><i> *</font></i>
<a name="33" href="#33">33</a> <font color="#329900"><i> * 5. Products derived from this software may not be called "Apache"</font></i>
<a name="34" href="#34">34</a> <font color="#329900"><i> * nor may "Apache" appear in their names without prior written</font></i>
<a name="35" href="#35">35</a> <font color="#329900"><i> * permission of the Apache Group.</font></i>
<a name="36" href="#36">36</a> <font color="#329900"><i> *</font></i>
<a name="37" href="#37">37</a> <font color="#329900"><i> * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED</font></i>
<a name="38" href="#38">38</a> <font color="#329900"><i> * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES</font></i>
<a name="39" href="#39">39</a> <font color="#329900"><i> * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE</font></i>
<a name="40" href="#40">40</a> <font color="#329900"><i> * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR</font></i>
<a name="41" href="#41">41</a> <font color="#329900"><i> * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,</font></i>
<a name="42" href="#42">42</a> <font color="#329900"><i> * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT</font></i>
<a name="43" href="#43">43</a> <font color="#329900"><i> * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF</font></i>
<a name="44" href="#44">44</a> <font color="#329900"><i> * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND</font></i>
<a name="45" href="#45">45</a> <font color="#329900"><i> * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,</font></i>
<a name="46" href="#46">46</a> <font color="#329900"><i> * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT</font></i>
<a name="47" href="#47">47</a> <font color="#329900"><i> * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF</font></i>
<a name="48" href="#48">48</a> <font color="#329900"><i> * SUCH DAMAGE.</font></i>
<a name="49" href="#49">49</a> <font color="#329900"><i> * ====================================================================</font></i>
<a name="50" href="#50">50</a> <font color="#329900"><i> *</font></i>
<a name="51" href="#51">51</a> <font color="#329900"><i> * This software consists of voluntary contributions made by many</font></i>
<a name="52" href="#52">52</a> <font color="#329900"><i> * individuals on behalf of the Apache Software Foundation. For more</font></i>
<a name="53" href="#53">53</a> <font color="#329900"><i> * information on the Apache Software Foundation, please see</font></i>
<a name="54" href="#54">54</a> <font color="#329900"><i> * <<a href="http://www.apache.org/>" target="alexandria_uri">http://www.apache.org/></a>;.</font></i>
<a name="55" href="#55">55</a> <font color="#329900"><i> *</font></i>
<a name="56" href="#56">56</a> <font color="#329900"><i> * [Additional notices, if required by prior licensing conditions]</font></i>
<a name="57" href="#57">57</a> <font color="#329900"><i> *</font></i>
<a name="58" href="#58">58</a> <font color="#329900"><i> */</font></i>
<a name="59" href="#59">59</a>
<a name="60" href="#60">60</a> <b>package</b> <a href="../../../../../org/apache/commons/latka/validators/index.html">org.apache.commons.latka.validators</a>;
<a name="61" href="#61">61</a>
<a name="62" href="#62">62</a> <b>import</b> <a href="../../../../../org/apache/commons/latka/xml/index.html">org.apache.commons.latka.xml</a>.<a href="../../../../../org/apache/commons/latka/xml/ValidationHandler.html">ValidationHandler</a>;
<a name="63" href="#63">63</a>
<a name="64" href="#64">64</a> <b>import</b> org.xml.sax.Attributes;
<a name="65" href="#65">65</a> <b>import</b> org.xml.sax.SAXException;
<a name="66" href="#66">66</a>
<a name="67" href="#67">67</a> <font color="#AA0000"><i>/**<font color="#AA0000"><i>*</font></i></font></i>
<a name="68" href="#68">68</a> <font color="#AA0000"><i> * Handler for the {@link XPathValidator} class.</font></i>
<a name="69" href="#69">69</a> <font color="#AA0000"><i> *</font></i>
<a name="70" href="#70">70</a> <font color="#AA0000"><i> * @author <a href="<a href="mailto:jefft@apache.org" target="alexandria_uri">mailto:jefft@apache.org</a>">Jeff Turner</a></font></i>
<a name="71" href="#71">71</a> <font color="#AA0000"><i> * @since 6 January, 2001</font></i>
<a name="72" href="#72">72</a> <font color="#AA0000"><i> */</font></i>
<a name="73" href="#73">73</a> <b>public</b> <b>class</b> <a href="../../../../../org/apache/commons/latka/validators/XPathHandler.html">XPathHandler</a> <b>extends</b> <a href="../../../../../org/apache/commons/latka/xml/ValidationHandler.html">ValidationHandler</a> {
<a name="74" href="#74">74</a>
<a name="75" href="#75">75</a> <b>public</b> <b>void</b> startElement(String uri, String localName,
<a name="76" href="#76">76</a> String qName, Attributes atts)
<a name="77" href="#77">77</a> throws SAXException {
<a name="78" href="#78">78</a>
<a name="79" href="#79">79</a> log.debug(localName);
<a name="80" href="#80">80</a>
<a name="81" href="#81">81</a> <a href="../../../../../org/apache/commons/latka/validators/XPathValidator.html">XPathValidator</a> validator =
<a name="82" href="#82">82</a> <b>new</b> <a href="../../../../../org/apache/commons/latka/validators/XPathValidator.html">XPathValidator</a>(atts.getValue(<font color="#000099">"label"</font>));
<a name="83" href="#83">83</a> validator.setSelect(atts.getValue(<font color="#000099">"select"</font>));
<a name="84" href="#84">84</a> validator.setValue(atts.getValue(<font color="#000099">"value"</font>));
<a name="85" href="#85">85</a>
<a name="86" href="#86">86</a> String cond = atts.getValue(<font color="#000099">"cond"</font>);
<a name="87" href="#87">87</a> <b>if</b> (cond != <b>null</b>) {
<a name="88" href="#88">88</a> validator.setCondition(Boolean.valueOf(cond).booleanValue());
<a name="89" href="#89">89</a> }
<a name="90" href="#90">90</a>
<a name="91" href="#91">91</a> validate(validator);
<a name="92" href="#92">92</a> }
<a name="93" href="#93">93</a> }
</pre>
<hr><center>This page automatically generated by Maven</center></body>
</html>
1.1 jakarta-commons/docs/latka/xref/java/org/apache/commons/latka/validators/StatusCodeValidator.html
Index: StatusCodeValidator.html
===================================================================
<html>
<body bgcolor="white">
<pre>
<table bgcolor="#FFFFCC" cellpadding="0" cellspacing="0" border="0" width="100%"><a href="../../../../../../../apidocs/org/apache/commons/latka/validators/StatusCodeValidator.html">View Javadoc</a></table>
<a name="1" href="#1">1</a> <font color="#329900"><i>/*</font></i>
<a name="2" href="#2">2</a> <font color="#329900"><i> * ====================================================================</font></i>
<a name="3" href="#3">3</a> <font color="#329900"><i> *</font></i>
<a name="4" href="#4">4</a> <font color="#329900"><i> * The Apache Software License, Version 1.1</font></i>
<a name="5" href="#5">5</a> <font color="#329900"><i> *</font></i>
<a name="6" href="#6">6</a> <font color="#329900"><i> * Copyright (c) 1999 The Apache Software Foundation. All rights </font></i>
<a name="7" href="#7">7</a> <font color="#329900"><i> * reserved.</font></i>
<a name="8" href="#8">8</a> <font color="#329900"><i> *</font></i>
<a name="9" href="#9">9</a> <font color="#329900"><i> * Redistribution and use in source and binary forms, with or without</font></i>
<a name="10" href="#10">10</a> <font color="#329900"><i> * modification, are permitted provided that the following conditions</font></i>
<a name="11" href="#11">11</a> <font color="#329900"><i> * are met:</font></i>
<a name="12" href="#12">12</a> <font color="#329900"><i> *</font></i>
<a name="13" href="#13">13</a> <font color="#329900"><i> * 1. Redistributions of source code must retain the above copyright</font></i>
<a name="14" href="#14">14</a> <font color="#329900"><i> * notice, this list of conditions and the following disclaimer. </font></i>
<a name="15" href="#15">15</a> <font color="#329900"><i> *</font></i>
<a name="16" href="#16">16</a> <font color="#329900"><i> * 2. Redistributions in binary form must reproduce the above copyright</font></i>
<a name="17" href="#17">17</a> <font color="#329900"><i> * notice, this list of conditions and the following disclaimer in</font></i>
<a name="18" href="#18">18</a> <font color="#329900"><i> * the documentation and/or other materials provided with the</font></i>
<a name="19" href="#19">19</a> <font color="#329900"><i> * distribution.</font></i>
<a name="20" href="#20">20</a> <font color="#329900"><i> *</font></i>
<a name="21" href="#21">21</a> <font color="#329900"><i> * 3. The end-user documentation included with the redistribution, if</font></i>
<a name="22" href="#22">22</a> <font color="#329900"><i> * any, must include the following acknowlegement: </font></i>
<a name="23" href="#23">23</a> <font color="#329900"><i> * "This product includes software developed by the </font></i>
<a name="24" href="#24">24</a> <font color="#329900"><i> * Apache Software Foundation (<a href="http://www.apache.org/" target="alexandria_uri">http://www.apache.org/</a>)."</font></i>
<a name="25" href="#25">25</a> <font color="#329900"><i> * Alternately, this acknowlegement may appear in the software itself,</font></i>
<a name="26" href="#26">26</a> <font color="#329900"><i> * if and wherever such third-party acknowlegements normally appear.</font></i>
<a name="27" href="#27">27</a> <font color="#329900"><i> *</font></i>
<a name="28" href="#28">28</a> <font color="#329900"><i> * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software</font></i>
<a name="29" href="#29">29</a> <font color="#329900"><i> * Foundation" must not be used to endorse or promote products derived</font></i>
<a name="30" href="#30">30</a> <font color="#329900"><i> * from this software without prior written permission. For written </font></i>
<a name="31" href="#31">31</a> <font color="#329900"><i> * permission, please contact apache@apache.org.</font></i>
<a name="32" href="#32">32</a> <font color="#329900"><i> *</font></i>
<a name="33" href="#33">33</a> <font color="#329900"><i> * 5. Products derived from this software may not be called "Apache"</font></i>
<a name="34" href="#34">34</a> <font color="#329900"><i> * nor may "Apache" appear in their names without prior written</font></i>
<a name="35" href="#35">35</a> <font color="#329900"><i> * permission of the Apache Group.</font></i>
<a name="36" href="#36">36</a> <font color="#329900"><i> *</font></i>
<a name="37" href="#37">37</a> <font color="#329900"><i> * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED</font></i>
<a name="38" href="#38">38</a> <font color="#329900"><i> * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES</font></i>
<a name="39" href="#39">39</a> <font color="#329900"><i> * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE</font></i>
<a name="40" href="#40">40</a> <font color="#329900"><i> * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR</font></i>
<a name="41" href="#41">41</a> <font color="#329900"><i> * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,</font></i>
<a name="42" href="#42">42</a> <font color="#329900"><i> * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT</font></i>
<a name="43" href="#43">43</a> <font color="#329900"><i> * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF</font></i>
<a name="44" href="#44">44</a> <font color="#329900"><i> * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND</font></i>
<a name="45" href="#45">45</a> <font color="#329900"><i> * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,</font></i>
<a name="46" href="#46">46</a> <font color="#329900"><i> * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT</font></i>
<a name="47" href="#47">47</a> <font color="#329900"><i> * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF</font></i>
<a name="48" href="#48">48</a> <font color="#329900"><i> * SUCH DAMAGE.</font></i>
<a name="49" href="#49">49</a> <font color="#329900"><i> * ====================================================================</font></i>
<a name="50" href="#50">50</a> <font color="#329900"><i> *</font></i>
<a name="51" href="#51">51</a> <font color="#329900"><i> * This software consists of voluntary contributions made by many</font></i>
<a name="52" href="#52">52</a> <font color="#329900"><i> * individuals on behalf of the Apache Software Foundation. For more</font></i>
<a name="53" href="#53">53</a> <font color="#329900"><i> * information on the Apache Software Foundation, please see</font></i>
<a name="54" href="#54">54</a> <font color="#329900"><i> * <<a href="http://www.apache.org/>" target="alexandria_uri">http://www.apache.org/></a>;.</font></i>
<a name="55" href="#55">55</a> <font color="#329900"><i> *</font></i>
<a name="56" href="#56">56</a> <font color="#329900"><i> * [Additional notices, if required by prior licensing conditions]</font></i>
<a name="57" href="#57">57</a> <font color="#329900"><i> *</font></i>
<a name="58" href="#58">58</a> <font color="#329900"><i> */</font></i>
<a name="59" href="#59">59</a>
<a name="60" href="#60">60</a> <b>package</b> <a href="../../../../../org/apache/commons/latka/validators/index.html">org.apache.commons.latka.validators</a>;
<a name="61" href="#61">61</a>
<a name="62" href="#62">62</a> <b>import</b> <a href="../../../../../org/apache/commons/latka/index.html">org.apache.commons.latka</a>.<a href="../../../../../org/apache/commons/latka/Validator.html">Validator</a>;
<a name="63" href="#63">63</a> <b>import</b> <a href="../../../../../org/apache/commons/latka/index.html">org.apache.commons.latka</a>.<a href="../../../../../org/apache/commons/latka/ValidationException.html">ValidationException</a>;
<a name="64" href="#64">64</a>
<a name="65" href="#65">65</a> <b>import</b> <a href="../../../../../org/apache/commons/latka/http/index.html">org.apache.commons.latka.http</a>.<a href="../../../../../org/apache/commons/latka/http/Response.html">Response</a>;
<a name="66" href="#66">66</a>
<a name="67" href="#67">67</a> <b>import</b> java.text.MessageFormat;
<a name="68" href="#68">68</a>
<a name="69" href="#69">69</a> <font color="#AA0000"><i>/**<font color="#AA0000"><i>*</font></i></font></i>
<a name="70" href="#70">70</a> <font color="#AA0000"><i> * FIXME: Docs</font></i>
<a name="71" href="#71">71</a> <font color="#AA0000"><i> *</font></i>
<a name="72" href="#72">72</a> <font color="#AA0000"><i> * @author Morgan Delagrange</font></i>
<a name="73" href="#73">73</a> <font color="#AA0000"><i> * @author dIon Gillard</font></i>
<a name="74" href="#74">74</a> <font color="#AA0000"><i> * @version $Id: StatusCodeValidator.html,v 1.1 2002/04/01 05:44:07 dion Exp $</font></i>
<a name="75" href="#75">75</a> <font color="#AA0000"><i> */</font></i>
<a name="76" href="#76">76</a> <b>public</b> <b>class</b> <a href="../../../../../org/apache/commons/latka/validators/StatusCodeValidator.html">StatusCodeValidator</a> <b>extends</b> <a href="../../../../../org/apache/commons/latka/validators/BaseValidator.html">BaseValidator</a> implements <a href="../../../../../org/apache/commons/latka/Validator.html">Validator</a> {
<a name="77" href="#77">77</a>
<a name="78" href="#78">78</a> <font color="#329900"><i>// --------------------------------------------------------------- Attributes</font></i>
<a name="79" href="#79">79</a>
<a name="80" href="#80">80</a> <b>protected</b> <b>static</b> <b>final</b> MessageFormat MESSAGE = <b>new</b> MessageFormat(<font color="#000099">"Expected status code \"{0,number,000}\". Found \"{1,number,000}\"."</font>);
<a name="81" href="#81">81</a> <b>protected</b> <b>int</b> _statusCode = 200;
<a name="82" href="#82">82</a>
<a name="83" href="#83">83</a> <font color="#329900"><i>// ------------------------------------------------------------- Constructors</font></i>
<a name="84" href="#84">84</a>
<a name="85" href="#85">85</a> <b>public</b> <a href="../../../../../org/apache/commons/latka/validators/StatusCodeValidator.html">StatusCodeValidator</a>() {
<a name="86" href="#86">86</a> <b>this</b>(<b>null</b>,200);
<a name="87" href="#87">87</a> }
<a name="88" href="#88">88</a>
<a name="89" href="#89">89</a> <b>public</b> <a href="../../../../../org/apache/commons/latka/validators/StatusCodeValidator.html">StatusCodeValidator</a>(<b>int</b> code) {
<a name="90" href="#90">90</a> <b>this</b>(<b>null</b>,code);
<a name="91" href="#91">91</a> }
<a name="92" href="#92">92</a>
<a name="93" href="#93">93</a> <b>public</b> <a href="../../../../../org/apache/commons/latka/validators/StatusCodeValidator.html">StatusCodeValidator</a>(String label) {
<a name="94" href="#94">94</a> <b>this</b>(label,200);
<a name="95" href="#95">95</a> }
<a name="96" href="#96">96</a>
<a name="97" href="#97">97</a> <b>public</b> <a href="../../../../../org/apache/commons/latka/validators/StatusCodeValidator.html">StatusCodeValidator</a>(String label, <b>int</b> code) {
<a name="98" href="#98">98</a> <b>super</b>(label);
<a name="99" href="#99">99</a> _statusCode = code;
<a name="100" href="#100">100</a> }
<a name="101" href="#101">101</a>
<a name="102" href="#102">102</a> <font color="#329900"><i>// ------------------------------------------------------------------ Methods</font></i>
<a name="103" href="#103">103</a>
<a name="104" href="#104">104</a> <b>public</b> <b>void</b> setStatusCode(<b>int</b> statusCode) {
<a name="105" href="#105">105</a> _statusCode = statusCode;
<a name="106" href="#106">106</a> }
<a name="107" href="#107">107</a>
<a name="108" href="#108">108</a> <b>public</b> <b>void</b> validate(<a href="../../../../../org/apache/commons/latka/http/Response.html">Response</a> response)
<a name="109" href="#109">109</a> throws <a href="../../../../../org/apache/commons/latka/ValidationException.html">ValidationException</a> {
<a name="110" href="#110">110</a>
<a name="111" href="#111">111</a> <b>int</b> responseStatusCode = response.getStatusCode();
<a name="112" href="#112">112</a>
<a name="113" href="#113">113</a> <b>if</b> (_statusCode != responseStatusCode) {
<a name="114" href="#114">114</a> fail(MESSAGE.format(<b>new</b> Object[] { <b>new</b> Integer(_statusCode), <b>new</b> Integer(responseStatusCode) }).toString());
<a name="115" href="#115">115</a> }
<a name="116" href="#116">116</a> }
<a name="117" href="#117">117</a> }
</pre>
<hr><center>This page automatically generated by Maven</center></body>
</html>
1.1 jakarta-commons/docs/latka/xref/java/org/apache/commons/latka/validators/StatusCodeHandler.html
Index: StatusCodeHandler.html
===================================================================
<html>
<body bgcolor="white">
<pre>
<table bgcolor="#FFFFCC" cellpadding="0" cellspacing="0" border="0" width="100%"><a href="../../../../../../../apidocs/org/apache/commons/latka/validators/StatusCodeHandler.html">View Javadoc</a></table>
<a name="1" href="#1">1</a> <font color="#329900"><i>/*</font></i>
<a name="2" href="#2">2</a> <font color="#329900"><i> * ====================================================================</font></i>
<a name="3" href="#3">3</a> <font color="#329900"><i> *</font></i>
<a name="4" href="#4">4</a> <font color="#329900"><i> * The Apache Software License, Version 1.1</font></i>
<a name="5" href="#5">5</a> <font color="#329900"><i> *</font></i>
<a name="6" href="#6">6</a> <font color="#329900"><i> * Copyright (c) 1999 The Apache Software Foundation. All rights </font></i>
<a name="7" href="#7">7</a> <font color="#329900"><i> * reserved.</font></i>
<a name="8" href="#8">8</a> <font color="#329900"><i> *</font></i>
<a name="9" href="#9">9</a> <font color="#329900"><i> * Redistribution and use in source and binary forms, with or without</font></i>
<a name="10" href="#10">10</a> <font color="#329900"><i> * modification, are permitted provided that the following conditions</font></i>
<a name="11" href="#11">11</a> <font color="#329900"><i> * are met:</font></i>
<a name="12" href="#12">12</a> <font color="#329900"><i> *</font></i>
<a name="13" href="#13">13</a> <font color="#329900"><i> * 1. Redistributions of source code must retain the above copyright</font></i>
<a name="14" href="#14">14</a> <font color="#329900"><i> * notice, this list of conditions and the following disclaimer. </font></i>
<a name="15" href="#15">15</a> <font color="#329900"><i> *</font></i>
<a name="16" href="#16">16</a> <font color="#329900"><i> * 2. Redistributions in binary form must reproduce the above copyright</font></i>
<a name="17" href="#17">17</a> <font color="#329900"><i> * notice, this list of conditions and the following disclaimer in</font></i>
<a name="18" href="#18">18</a> <font color="#329900"><i> * the documentation and/or other materials provided with the</font></i>
<a name="19" href="#19">19</a> <font color="#329900"><i> * distribution.</font></i>
<a name="20" href="#20">20</a> <font color="#329900"><i> *</font></i>
<a name="21" href="#21">21</a> <font color="#329900"><i> * 3. The end-user documentation included with the redistribution, if</font></i>
<a name="22" href="#22">22</a> <font color="#329900"><i> * any, must include the following acknowlegement: </font></i>
<a name="23" href="#23">23</a> <font color="#329900"><i> * "This product includes software developed by the </font></i>
<a name="24" href="#24">24</a> <font color="#329900"><i> * Apache Software Foundation (<a href="http://www.apache.org/" target="alexandria_uri">http://www.apache.org/</a>)."</font></i>
<a name="25" href="#25">25</a> <font color="#329900"><i> * Alternately, this acknowlegement may appear in the software itself,</font></i>
<a name="26" href="#26">26</a> <font color="#329900"><i> * if and wherever such third-party acknowlegements normally appear.</font></i>
<a name="27" href="#27">27</a> <font color="#329900"><i> *</font></i>
<a name="28" href="#28">28</a> <font color="#329900"><i> * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software</font></i>
<a name="29" href="#29">29</a> <font color="#329900"><i> * Foundation" must not be used to endorse or promote products derived</font></i>
<a name="30" href="#30">30</a> <font color="#329900"><i> * from this software without prior written permission. For written </font></i>
<a name="31" href="#31">31</a> <font color="#329900"><i> * permission, please contact apache@apache.org.</font></i>
<a name="32" href="#32">32</a> <font color="#329900"><i> *</font></i>
<a name="33" href="#33">33</a> <font color="#329900"><i> * 5. Products derived from this software may not be called "Apache"</font></i>
<a name="34" href="#34">34</a> <font color="#329900"><i> * nor may "Apache" appear in their names without prior written</font></i>
<a name="35" href="#35">35</a> <font color="#329900"><i> * permission of the Apache Group.</font></i>
<a name="36" href="#36">36</a> <font color="#329900"><i> *</font></i>
<a name="37" href="#37">37</a> <font color="#329900"><i> * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED</font></i>
<a name="38" href="#38">38</a> <font color="#329900"><i> * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES</font></i>
<a name="39" href="#39">39</a> <font color="#329900"><i> * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE</font></i>
<a name="40" href="#40">40</a> <font color="#329900"><i> * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR</font></i>
<a name="41" href="#41">41</a> <font color="#329900"><i> * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,</font></i>
<a name="42" href="#42">42</a> <font color="#329900"><i> * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT</font></i>
<a name="43" href="#43">43</a> <font color="#329900"><i> * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF</font></i>
<a name="44" href="#44">44</a> <font color="#329900"><i> * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND</font></i>
<a name="45" href="#45">45</a> <font color="#329900"><i> * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,</font></i>
<a name="46" href="#46">46</a> <font color="#329900"><i> * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT</font></i>
<a name="47" href="#47">47</a> <font color="#329900"><i> * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF</font></i>
<a name="48" href="#48">48</a> <font color="#329900"><i> * SUCH DAMAGE.</font></i>
<a name="49" href="#49">49</a> <font color="#329900"><i> * ====================================================================</font></i>
<a name="50" href="#50">50</a> <font color="#329900"><i> *</font></i>
<a name="51" href="#51">51</a> <font color="#329900"><i> * This software consists of voluntary contributions made by many</font></i>
<a name="52" href="#52">52</a> <font color="#329900"><i> * individuals on behalf of the Apache Software Foundation. For more</font></i>
<a name="53" href="#53">53</a> <font color="#329900"><i> * information on the Apache Software Foundation, please see</font></i>
<a name="54" href="#54">54</a> <font color="#329900"><i> * <<a href="http://www.apache.org/>" target="alexandria_uri">http://www.apache.org/></a>;.</font></i>
<a name="55" href="#55">55</a> <font color="#329900"><i> *</font></i>
<a name="56" href="#56">56</a> <font color="#329900"><i> * [Additional notices, if required by prior licensing conditions]</font></i>
<a name="57" href="#57">57</a> <font color="#329900"><i> *</font></i>
<a name="58" href="#58">58</a> <font color="#329900"><i> */</font></i>
<a name="59" href="#59">59</a>
<a name="60" href="#60">60</a> <b>package</b> <a href="../../../../../org/apache/commons/latka/validators/index.html">org.apache.commons.latka.validators</a>;
<a name="61" href="#61">61</a>
<a name="62" href="#62">62</a> <b>import</b> <a href="../../../../../org/apache/commons/latka/xml/index.html">org.apache.commons.latka.xml</a>.<a href="../../../../../org/apache/commons/latka/xml/ValidationHandler.html">ValidationHandler</a>;
<a name="63" href="#63">63</a>
<a name="64" href="#64">64</a> <b>import</b> org.xml.sax.Attributes;
<a name="65" href="#65">65</a> <b>import</b> org.xml.sax.SAXException;
<a name="66" href="#66">66</a>
<a name="67" href="#67">67</a> <b>public</b> <b>class</b> <a href="../../../../../org/apache/commons/latka/validators/StatusCodeHandler.html">StatusCodeHandler</a> <b>extends</b> <a href="../../../../../org/apache/commons/latka/xml/ValidationHandler.html">ValidationHandler</a> {
<a name="68" href="#68">68</a>
<a name="69" href="#69">69</a> <b>public</b> <b>void</b> startElement(String uri, String localName,
<a name="70" href="#70">70</a> String qName, Attributes atts)
<a name="71" href="#71">71</a> throws SAXException {
<a name="72" href="#72">72</a>
<a name="73" href="#73">73</a> <a href="../../../../../org/apache/commons/latka/validators/StatusCodeValidator.html">StatusCodeValidator</a> validator =
<a name="74" href="#74">74</a> <b>new</b> <a href="../../../../../org/apache/commons/latka/validators/StatusCodeValidator.html">StatusCodeValidator</a>(atts.getValue(<font color="#000099">"label"</font>));
<a name="75" href="#75">75</a>
<a name="76" href="#76">76</a> String codeString = atts.getValue(<font color="#000099">"code"</font>);
<a name="77" href="#77">77</a> <b>if</b> (codeString != <b>null</b>) {
<a name="78" href="#78">78</a> validator.setStatusCode(Integer.parseInt(codeString));
<a name="79" href="#79">79</a> }
<a name="80" href="#80">80</a>
<a name="81" href="#81">81</a> validate(validator);
<a name="82" href="#82">82</a>
<a name="83" href="#83">83</a> }
<a name="84" href="#84">84</a>
<a name="85" href="#85">85</a> }
</pre>
<hr><center>This page automatically generated by Maven</center></body>
</html>
1.1 jakarta-commons/docs/latka/xref/java/org/apache/commons/latka/validators/RegexpValidator.html
Index: RegexpValidator.html
===================================================================
<html>
<body bgcolor="white">
<pre>
<table bgcolor="#FFFFCC" cellpadding="0" cellspacing="0" border="0" width="100%"><a href="../../../../../../../apidocs/org/apache/commons/latka/validators/RegexpValidator.html">View Javadoc</a></table>
<a name="1" href="#1">1</a>
<a name="2" href="#2">2</a> <font color="#329900"><i>/*</font></i>
<a name="3" href="#3">3</a> <font color="#329900"><i> * ====================================================================</font></i>
<a name="4" href="#4">4</a> <font color="#329900"><i> *</font></i>
<a name="5" href="#5">5</a> <font color="#329900"><i> * The Apache Software License, Version 1.1</font></i>
<a name="6" href="#6">6</a> <font color="#329900"><i> *</font></i>
<a name="7" href="#7">7</a> <font color="#329900"><i> * Copyright (c) 1999 The Apache Software Foundation. All rights </font></i>
<a name="8" href="#8">8</a> <font color="#329900"><i> * reserved.</font></i>
<a name="9" href="#9">9</a> <font color="#329900"><i> *</font></i>
<a name="10" href="#10">10</a> <font color="#329900"><i> * Redistribution and use in source and binary forms, with or without</font></i>
<a name="11" href="#11">11</a> <font color="#329900"><i> * modification, are permitted provided that the following conditions</font></i>
<a name="12" href="#12">12</a> <font color="#329900"><i> * are met:</font></i>
<a name="13" href="#13">13</a> <font color="#329900"><i> *</font></i>
<a name="14" href="#14">14</a> <font color="#329900"><i> * 1. Redistributions of source code must retain the above copyright</font></i>
<a name="15" href="#15">15</a> <font color="#329900"><i> * notice, this list of conditions and the following disclaimer. </font></i>
<a name="16" href="#16">16</a> <font color="#329900"><i> *</font></i>
<a name="17" href="#17">17</a> <font color="#329900"><i> * 2. Redistributions in binary form must reproduce the above copyright</font></i>
<a name="18" href="#18">18</a> <font color="#329900"><i> * notice, this list of conditions and the following disclaimer in</font></i>
<a name="19" href="#19">19</a> <font color="#329900"><i> * the documentation and/or other materials provided with the</font></i>
<a name="20" href="#20">20</a> <font color="#329900"><i> * distribution.</font></i>
<a name="21" href="#21">21</a> <font color="#329900"><i> *</font></i>
<a name="22" href="#22">22</a> <font color="#329900"><i> * 3. The end-user documentation included with the redistribution, if</font></i>
<a name="23" href="#23">23</a> <font color="#329900"><i> * any, must include the following acknowlegement: </font></i>
<a name="24" href="#24">24</a> <font color="#329900"><i> * "This product includes software developed by the </font></i>
<a name="25" href="#25">25</a> <font color="#329900"><i> * Apache Software Foundation (<a href="http://www.apache.org/" target="alexandria_uri">http://www.apache.org/</a>)."</font></i>
<a name="26" href="#26">26</a> <font color="#329900"><i> * Alternately, this acknowlegement may appear in the software itself,</font></i>
<a name="27" href="#27">27</a> <font color="#329900"><i> * if and wherever such third-party acknowlegements normally appear.</font></i>
<a name="28" href="#28">28</a> <font color="#329900"><i> *</font></i>
<a name="29" href="#29">29</a> <font color="#329900"><i> * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software</font></i>
<a name="30" href="#30">30</a> <font color="#329900"><i> * Foundation" must not be used to endorse or promote products derived</font></i>
<a name="31" href="#31">31</a> <font color="#329900"><i> * from this software without prior written permission. For written </font></i>
<a name="32" href="#32">32</a> <font color="#329900"><i> * permission, please contact apache@apache.org.</font></i>
<a name="33" href="#33">33</a> <font color="#329900"><i> *</font></i>
<a name="34" href="#34">34</a> <font color="#329900"><i> * 5. Products derived from this software may not be called "Apache"</font></i>
<a name="35" href="#35">35</a> <font color="#329900"><i> * nor may "Apache" appear in their names without prior written</font></i>
<a name="36" href="#36">36</a> <font color="#329900"><i> * permission of the Apache Group.</font></i>
<a name="37" href="#37">37</a> <font color="#329900"><i> *</font></i>
<a name="38" href="#38">38</a> <font color="#329900"><i> * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED</font></i>
<a name="39" href="#39">39</a> <font color="#329900"><i> * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES</font></i>
<a name="40" href="#40">40</a> <font color="#329900"><i> * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE</font></i>
<a name="41" href="#41">41</a> <font color="#329900"><i> * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR</font></i>
<a name="42" href="#42">42</a> <font color="#329900"><i> * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,</font></i>
<a name="43" href="#43">43</a> <font color="#329900"><i> * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT</font></i>
<a name="44" href="#44">44</a> <font color="#329900"><i> * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF</font></i>
<a name="45" href="#45">45</a> <font color="#329900"><i> * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND</font></i>
<a name="46" href="#46">46</a> <font color="#329900"><i> * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,</font></i>
<a name="47" href="#47">47</a> <font color="#329900"><i> * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT</font></i>
<a name="48" href="#48">48</a> <font color="#329900"><i> * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF</font></i>
<a name="49" href="#49">49</a> <font color="#329900"><i> * SUCH DAMAGE.</font></i>
<a name="50" href="#50">50</a> <font color="#329900"><i> * ====================================================================</font></i>
<a name="51" href="#51">51</a> <font color="#329900"><i> *</font></i>
<a name="52" href="#52">52</a> <font color="#329900"><i> * This software consists of voluntary contributions made by many</font></i>
<a name="53" href="#53">53</a> <font color="#329900"><i> * individuals on behalf of the Apache Software Foundation. For more</font></i>
<a name="54" href="#54">54</a> <font color="#329900"><i> * information on the Apache Software Foundation, please see</font></i>
<a name="55" href="#55">55</a> <font color="#329900"><i> * <<a href="http://www.apache.org/>" target="alexandria_uri">http://www.apache.org/></a>;.</font></i>
<a name="56" href="#56">56</a> <font color="#329900"><i> *</font></i>
<a name="57" href="#57">57</a> <font color="#329900"><i> * [Additional notices, if required by prior licensing conditions]</font></i>
<a name="58" href="#58">58</a> <font color="#329900"><i> *</font></i>
<a name="59" href="#59">59</a> <font color="#329900"><i> */</font></i>
<a name="60" href="#60">60</a> <b>package</b> <a href="../../../../../org/apache/commons/latka/validators/index.html">org.apache.commons.latka.validators</a>;
<a name="61" href="#61">61</a>
<a name="62" href="#62">62</a> <b>import</b> <a href="../../../../../org/apache/commons/latka/index.html">org.apache.commons.latka</a>.<a href="../../../../../org/apache/commons/latka/Validator.html">Validator</a>;
<a name="63" href="#63">63</a> <b>import</b> <a href="../../../../../org/apache/commons/latka/index.html">org.apache.commons.latka</a>.<a href="../../../../../org/apache/commons/latka/ValidationException.html">ValidationException</a>;
<a name="64" href="#64">64</a>
<a name="65" href="#65">65</a> <b>import</b> <a href="../../../../../org/apache/commons/latka/http/index.html">org.apache.commons.latka.http</a>.<a href="../../../../../org/apache/commons/latka/http/Response.html">Response</a>;
<a name="66" href="#66">66</a>
<a name="67" href="#67">67</a> <b>import</b> org.apache.regexp.RE;
<a name="68" href="#68">68</a> <b>import</b> org.apache.regexp.RESyntaxException;
<a name="69" href="#69">69</a>
<a name="70" href="#70">70</a> <font color="#AA0000"><i>/**<font color="#AA0000"><i>*</font></i></font></i>
<a name="71" href="#71">71</a> <font color="#AA0000"><i> * FIXME: Docs</font></i>
<a name="72" href="#72">72</a> <font color="#AA0000"><i> *</font></i>
<a name="73" href="#73">73</a> <font color="#AA0000"><i> * @author Morgan Delagrange</font></i>
<a name="74" href="#74">74</a> <font color="#AA0000"><i> * @author dIon Gillard</font></i>
<a name="75" href="#75">75</a> <font color="#AA0000"><i> * @version $Id: RegexpValidator.html,v 1.1 2002/04/01 05:44:07 dion Exp $</font></i>
<a name="76" href="#76">76</a> <font color="#AA0000"><i> */</font></i>
<a name="77" href="#77">77</a> <b>public</b> <b>class</b> <a href="../../../../../org/apache/commons/latka/validators/RegexpValidator.html">RegexpValidator</a> <b>extends</b> <a href="../../../../../org/apache/commons/latka/validators/BaseValidator.html">BaseValidator</a> implements <a href="../../../../../org/apache/commons/latka/Validator.html">Validator</a> {
<a name="78" href="#78">78</a>
<a name="79" href="#79">79</a> <font color="#329900"><i>// --------------------------------------------------------------- Attributes</font></i>
<a name="80" href="#80">80</a>
<a name="81" href="#81">81</a> <b>protected</b> String _pattern = <b>null</b>;
<a name="82" href="#82">82</a> <b>protected</b> <b>boolean</b> _cond = <b>true</b>;
<a name="83" href="#83">83</a> <b>protected</b> <b>boolean</b> _ignoreCase = false;
<a name="84" href="#84">84</a>
<a name="85" href="#85">85</a> <b>protected</b> <b>static</b> <b>final</b> String TRUE_MESSAGE = <font color="#000099">"EXPECTED TO MATCH PATTERN: "</font>;
<a name="86" href="#86">86</a> <b>protected</b> <b>static</b> <b>final</b> String FALSE_MESSAGE = <font color="#000099">"DID NOT EXPECT TO MATCH PATTERN: "</font>;
<a name="87" href="#87">87</a>
<a name="88" href="#88">88</a> <font color="#329900"><i>// ------------------------------------------------------------- Constructors</font></i>
<a name="89" href="#89">89</a>
<a name="90" href="#90">90</a> <b>public</b> <a href="../../../../../org/apache/commons/latka/validators/RegexpValidator.html">RegexpValidator</a>() {
<a name="91" href="#91">91</a> <b>this</b>(<b>null</b>,<b>null</b>,<b>true</b>,false);
<a name="92" href="#92">92</a> }
<a name="93" href="#93">93</a>
<a name="94" href="#94">94</a> <b>public</b> <a href="../../../../../org/apache/commons/latka/validators/RegexpValidator.html">RegexpValidator</a>(String label) {
<a name="95" href="#95">95</a> <b>this</b>(label,<b>null</b>,<b>true</b>,false);
<a name="96" href="#96">96</a> }
<a name="97" href="#97">97</a>
<a name="98" href="#98">98</a> <b>public</b> <a href="../../../../../org/apache/commons/latka/validators/RegexpValidator.html">RegexpValidator</a>(String label, String pattern, <b>boolean</b> cond, <b>boolean</b> ignoreCase) {
<a name="99" href="#99">99</a> <b>super</b>(label);
<a name="100" href="#100">100</a> _pattern = pattern;
<a name="101" href="#101">101</a> _cond = cond;
<a name="102" href="#102">102</a> _ignoreCase = ignoreCase;
<a name="103" href="#103">103</a> }
<a name="104" href="#104">104</a>
<a name="105" href="#105">105</a> <font color="#329900"><i>// ------------------------------------------------------------------ Methods</font></i>
<a name="106" href="#106">106</a>
<a name="107" href="#107">107</a> <b>public</b> <b>void</b> setPattern(String pattern) {
<a name="108" href="#108">108</a> _pattern = pattern;
<a name="109" href="#109">109</a> }
<a name="110" href="#110">110</a>
<a name="111" href="#111">111</a> <b>public</b> <b>void</b> setCondition(<b>boolean</b> cond) {
<a name="112" href="#112">112</a> _cond = cond;
<a name="113" href="#113">113</a> }
<a name="114" href="#114">114</a>
<a name="115" href="#115">115</a> <b>public</b> <b>void</b> setIgnoreCase(<b>boolean</b> ignoreCase) {
<a name="116" href="#116">116</a> _ignoreCase = ignoreCase;
<a name="117" href="#117">117</a> }
<a name="118" href="#118">118</a>
<a name="119" href="#119">119</a> <b>public</b> <b>void</b> validate(<a href="../../../../../org/apache/commons/latka/http/Response.html">Response</a> response)
<a name="120" href="#120">120</a> throws <a href="../../../../../org/apache/commons/latka/ValidationException.html">ValidationException</a> {
<a name="121" href="#121">121</a>
<a name="122" href="#122">122</a> RE r = <b>null</b>;
<a name="123" href="#123">123</a> <b>try</b> {
<a name="124" href="#124">124</a> r = <b>new</b> RE(_pattern); <font color="#329900"><i>// Compile expression</font></i>
<a name="125" href="#125">125</a> } <b>catch</b> (RESyntaxException e) {
<a name="126" href="#126">126</a> fail(e.toString());
<a name="127" href="#127">127</a> }
<a name="128" href="#128">128</a>
<a name="129" href="#129">129</a> <b>if</b> (_ignoreCase == <b>true</b>) {
<a name="130" href="#130">130</a> r.setMatchFlags(RE.MATCH_CASEINDEPENDENT);
<a name="131" href="#131">131</a> }
<a name="132" href="#132">132</a>
<a name="133" href="#133">133</a> <b>boolean</b> matched =
<a name="134" href="#134">134</a> r.match(response.getResource()); <font color="#329900"><i>// Match against expression</font></i>
<a name="135" href="#135">135</a> <b>if</b> (!(matched == _cond)) {
<a name="136" href="#136">136</a> StringBuffer buf = <b>new</b> StringBuffer();
<a name="137" href="#137">137</a> <b>if</b> (_cond == <b>true</b>) {
<a name="138" href="#138">138</a> buf.append(TRUE_MESSAGE);
<a name="139" href="#139">139</a> } <b>else</b> {
<a name="140" href="#140">140</a> buf.append(FALSE_MESSAGE);
<a name="141" href="#141">141</a> }
<a name="142" href="#142">142</a>
<a name="143" href="#143">143</a> buf.append(_pattern);
<a name="144" href="#144">144</a> fail(buf.toString());
<a name="145" href="#145">145</a> }
<a name="146" href="#146">146</a>
<a name="147" href="#147">147</a> }
<a name="148" href="#148">148</a>
<a name="149" href="#149">149</a> }
</pre>
<hr><center>This page automatically generated by Maven</center></body>
</html>
1.1 jakarta-commons/docs/latka/xref/java/org/apache/commons/latka/validators/RegexpHandler.html
Index: RegexpHandler.html
===================================================================
<html>
<body bgcolor="white">
<pre>
<table bgcolor="#FFFFCC" cellpadding="0" cellspacing="0" border="0" width="100%"><a href="../../../../../../../apidocs/org/apache/commons/latka/validators/RegexpHandler.html">View Javadoc</a></table>
<a name="1" href="#1">1</a> <font color="#329900"><i>/*</font></i>
<a name="2" href="#2">2</a> <font color="#329900"><i> * ====================================================================</font></i>
<a name="3" href="#3">3</a> <font color="#329900"><i> *</font></i>
<a name="4" href="#4">4</a> <font color="#329900"><i> * The Apache Software License, Version 1.1</font></i>
<a name="5" href="#5">5</a> <font color="#329900"><i> *</font></i>
<a name="6" href="#6">6</a> <font color="#329900"><i> * Copyright (c) 1999 The Apache Software Foundation. All rights </font></i>
<a name="7" href="#7">7</a> <font color="#329900"><i> * reserved.</font></i>
<a name="8" href="#8">8</a> <font color="#329900"><i> *</font></i>
<a name="9" href="#9">9</a> <font color="#329900"><i> * Redistribution and use in source and binary forms, with or without</font></i>
<a name="10" href="#10">10</a> <font color="#329900"><i> * modification, are permitted provided that the following conditions</font></i>
<a name="11" href="#11">11</a> <font color="#329900"><i> * are met:</font></i>
<a name="12" href="#12">12</a> <font color="#329900"><i> *</font></i>
<a name="13" href="#13">13</a> <font color="#329900"><i> * 1. Redistributions of source code must retain the above copyright</font></i>
<a name="14" href="#14">14</a> <font color="#329900"><i> * notice, this list of conditions and the following disclaimer. </font></i>
<a name="15" href="#15">15</a> <font color="#329900"><i> *</font></i>
<a name="16" href="#16">16</a> <font color="#329900"><i> * 2. Redistributions in binary form must reproduce the above copyright</font></i>
<a name="17" href="#17">17</a> <font color="#329900"><i> * notice, this list of conditions and the following disclaimer in</font></i>
<a name="18" href="#18">18</a> <font color="#329900"><i> * the documentation and/or other materials provided with the</font></i>
<a name="19" href="#19">19</a> <font color="#329900"><i> * distribution.</font></i>
<a name="20" href="#20">20</a> <font color="#329900"><i> *</font></i>
<a name="21" href="#21">21</a> <font color="#329900"><i> * 3. The end-user documentation included with the redistribution, if</font></i>
<a name="22" href="#22">22</a> <font color="#329900"><i> * any, must include the following acknowlegement: </font></i>
<a name="23" href="#23">23</a> <font color="#329900"><i> * "This product includes software developed by the </font></i>
<a name="24" href="#24">24</a> <font color="#329900"><i> * Apache Software Foundation (<a href="http://www.apache.org/" target="alexandria_uri">http://www.apache.org/</a>)."</font></i>
<a name="25" href="#25">25</a> <font color="#329900"><i> * Alternately, this acknowlegement may appear in the software itself,</font></i>
<a name="26" href="#26">26</a> <font color="#329900"><i> * if and wherever such third-party acknowlegements normally appear.</font></i>
<a name="27" href="#27">27</a> <font color="#329900"><i> *</font></i>
<a name="28" href="#28">28</a> <font color="#329900"><i> * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software</font></i>
<a name="29" href="#29">29</a> <font color="#329900"><i> * Foundation" must not be used to endorse or promote products derived</font></i>
<a name="30" href="#30">30</a> <font color="#329900"><i> * from this software without prior written permission. For written </font></i>
<a name="31" href="#31">31</a> <font color="#329900"><i> * permission, please contact apache@apache.org.</font></i>
<a name="32" href="#32">32</a> <font color="#329900"><i> *</font></i>
<a name="33" href="#33">33</a> <font color="#329900"><i> * 5. Products derived from this software may not be called "Apache"</font></i>
<a name="34" href="#34">34</a> <font color="#329900"><i> * nor may "Apache" appear in their names without prior written</font></i>
<a name="35" href="#35">35</a> <font color="#329900"><i> * permission of the Apache Group.</font></i>
<a name="36" href="#36">36</a> <font color="#329900"><i> *</font></i>
<a name="37" href="#37">37</a> <font color="#329900"><i> * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED</font></i>
<a name="38" href="#38">38</a> <font color="#329900"><i> * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES</font></i>
<a name="39" href="#39">39</a> <font color="#329900"><i> * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE</font></i>
<a name="40" href="#40">40</a> <font color="#329900"><i> * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR</font></i>
<a name="41" href="#41">41</a> <font color="#329900"><i> * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,</font></i>
<a name="42" href="#42">42</a> <font color="#329900"><i> * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT</font></i>
<a name="43" href="#43">43</a> <font color="#329900"><i> * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF</font></i>
<a name="44" href="#44">44</a> <font color="#329900"><i> * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND</font></i>
<a name="45" href="#45">45</a> <font color="#329900"><i> * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,</font></i>
<a name="46" href="#46">46</a> <font color="#329900"><i> * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT</font></i>
<a name="47" href="#47">47</a> <font color="#329900"><i> * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF</font></i>
<a name="48" href="#48">48</a> <font color="#329900"><i> * SUCH DAMAGE.</font></i>
<a name="49" href="#49">49</a> <font color="#329900"><i> * ====================================================================</font></i>
<a name="50" href="#50">50</a> <font color="#329900"><i> *</font></i>
<a name="51" href="#51">51</a> <font color="#329900"><i> * This software consists of voluntary contributions made by many</font></i>
<a name="52" href="#52">52</a> <font color="#329900"><i> * individuals on behalf of the Apache Software Foundation. For more</font></i>
<a name="53" href="#53">53</a> <font color="#329900"><i> * information on the Apache Software Foundation, please see</font></i>
<a name="54" href="#54">54</a> <font color="#329900"><i> * <<a href="http://www.apache.org/>" target="alexandria_uri">http://www.apache.org/></a>;.</font></i>
<a name="55" href="#55">55</a> <font color="#329900"><i> *</font></i>
<a name="56" href="#56">56</a> <font color="#329900"><i> * [Additional notices, if required by prior licensing conditions]</font></i>
<a name="57" href="#57">57</a> <font color="#329900"><i> *</font></i>
<a name="58" href="#58">58</a> <font color="#329900"><i> */</font></i>
<a name="59" href="#59">59</a>
<a name="60" href="#60">60</a> <b>package</b> <a href="../../../../../org/apache/commons/latka/validators/index.html">org.apache.commons.latka.validators</a>;
<a name="61" href="#61">61</a>
<a name="62" href="#62">62</a> <b>import</b> <a href="../../../../../org/apache/commons/latka/xml/index.html">org.apache.commons.latka.xml</a>.<a href="../../../../../org/apache/commons/latka/xml/ValidationHandler.html">ValidationHandler</a>;
<a name="63" href="#63">63</a>
<a name="64" href="#64">64</a> <b>import</b> org.xml.sax.Attributes;
<a name="65" href="#65">65</a> <b>import</b> org.xml.sax.SAXException;
<a name="66" href="#66">66</a>
<a name="67" href="#67">67</a> <b>public</b> <b>class</b> <a href="../../../../../org/apache/commons/latka/validators/RegexpHandler.html">RegexpHandler</a> <b>extends</b> <a href="../../../../../org/apache/commons/latka/xml/ValidationHandler.html">ValidationHandler</a> {
<a name="68" href="#68">68</a>
<a name="69" href="#69">69</a> <b>public</b> <b>void</b> startElement(String uri, String localName,
<a name="70" href="#70">70</a> String qName, Attributes atts)
<a name="71" href="#71">71</a> throws SAXException {
<a name="72" href="#72">72</a>
<a name="73" href="#73">73</a> log.debug(localName);
<a name="74" href="#74">74</a>
<a name="75" href="#75">75</a> <a href="../../../../../org/apache/commons/latka/validators/RegexpValidator.html">RegexpValidator</a> validator =
<a name="76" href="#76">76</a> <b>new</b> <a href="../../../../../org/apache/commons/latka/validators/RegexpValidator.html">RegexpValidator</a>(atts.getValue(<font color="#000099">"label"</font>));
<a name="77" href="#77">77</a> validator.setPattern(atts.getValue(<font color="#000099">"pattern"</font>));
<a name="78" href="#78">78</a>
<a name="79" href="#79">79</a> String cond = atts.getValue(<font color="#000099">"cond"</font>);
<a name="80" href="#80">80</a> <b>if</b> (cond != <b>null</b>) {
<a name="81" href="#81">81</a> validator.setCondition(Boolean.valueOf(cond).booleanValue());
<a name="82" href="#82">82</a> }
<a name="83" href="#83">83</a>
<a name="84" href="#84">84</a> <font color="#329900"><i>// a null will evaluate to the default "false"</font></i>
<a name="85" href="#85">85</a> validator.setIgnoreCase(Boolean.valueOf(atts.getValue(<font color="#000099">"ignoreCase"</font>)).booleanValue());
<a name="86" href="#86">86</a>
<a name="87" href="#87">87</a> validate(validator);
<a name="88" href="#88">88</a>
<a name="89" href="#89">89</a> }
<a name="90" href="#90">90</a>
<a name="91" href="#91">91</a> }
</pre>
<hr><center>This page automatically generated by Maven</center></body>
</html>
1.1 jakarta-commons/docs/latka/xref/java/org/apache/commons/latka/validators/MaxRequestTimeValidator.html
Index: MaxRequestTimeValidator.html
===================================================================
<html>
<body bgcolor="white">
<pre>
<table bgcolor="#FFFFCC" cellpadding="0" cellspacing="0" border="0" width="100%"><a href="../../../../../../../apidocs/org/apache/commons/latka/validators/MaxRequestTimeValidator.html">View Javadoc</a></table>
<a name="1" href="#1">1</a> <font color="#329900"><i>/*</font></i>
<a name="2" href="#2">2</a> <font color="#329900"><i> * ====================================================================</font></i>
<a name="3" href="#3">3</a> <font color="#329900"><i> *</font></i>
<a name="4" href="#4">4</a> <font color="#329900"><i> * The Apache Software License, Version 1.1</font></i>
<a name="5" href="#5">5</a> <font color="#329900"><i> *</font></i>
<a name="6" href="#6">6</a> <font color="#329900"><i> * Copyright (c) 1999 The Apache Software Foundation. All rights </font></i>
<a name="7" href="#7">7</a> <font color="#329900"><i> * reserved.</font></i>
<a name="8" href="#8">8</a> <font color="#329900"><i> *</font></i>
<a name="9" href="#9">9</a> <font color="#329900"><i> * Redistribution and use in source and binary forms, with or without</font></i>
<a name="10" href="#10">10</a> <font color="#329900"><i> * modification, are permitted provided that the following conditions</font></i>
<a name="11" href="#11">11</a> <font color="#329900"><i> * are met:</font></i>
<a name="12" href="#12">12</a> <font color="#329900"><i> *</font></i>
<a name="13" href="#13">13</a> <font color="#329900"><i> * 1. Redistributions of source code must retain the above copyright</font></i>
<a name="14" href="#14">14</a> <font color="#329900"><i> * notice, this list of conditions and the following disclaimer. </font></i>
<a name="15" href="#15">15</a> <font color="#329900"><i> *</font></i>
<a name="16" href="#16">16</a> <font color="#329900"><i> * 2. Redistributions in binary form must reproduce the above copyright</font></i>
<a name="17" href="#17">17</a> <font color="#329900"><i> * notice, this list of conditions and the following disclaimer in</font></i>
<a name="18" href="#18">18</a> <font color="#329900"><i> * the documentation and/or other materials provided with the</font></i>
<a name="19" href="#19">19</a> <font color="#329900"><i> * distribution.</font></i>
<a name="20" href="#20">20</a> <font color="#329900"><i> *</font></i>
<a name="21" href="#21">21</a> <font color="#329900"><i> * 3. The end-user documentation included with the redistribution, if</font></i>
<a name="22" href="#22">22</a> <font color="#329900"><i> * any, must include the following acknowlegement: </font></i>
<a name="23" href="#23">23</a> <font color="#329900"><i> * "This product includes software developed by the </font></i>
<a name="24" href="#24">24</a> <font color="#329900"><i> * Apache Software Foundation (<a href="http://www.apache.org/" target="alexandria_uri">http://www.apache.org/</a>)."</font></i>
<a name="25" href="#25">25</a> <font color="#329900"><i> * Alternately, this acknowlegement may appear in the software itself,</font></i>
<a name="26" href="#26">26</a> <font color="#329900"><i> * if and wherever such third-party acknowlegements normally appear.</font></i>
<a name="27" href="#27">27</a> <font color="#329900"><i> *</font></i>
<a name="28" href="#28">28</a> <font color="#329900"><i> * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software</font></i>
<a name="29" href="#29">29</a> <font color="#329900"><i> * Foundation" must not be used to endorse or promote products derived</font></i>
<a name="30" href="#30">30</a> <font color="#329900"><i> * from this software without prior written permission. For written </font></i>
<a name="31" href="#31">31</a> <font color="#329900"><i> * permission, please contact apache@apache.org.</font></i>
<a name="32" href="#32">32</a> <font color="#329900"><i> *</font></i>
<a name="33" href="#33">33</a> <font color="#329900"><i> * 5. Products derived from this software may not be called "Apache"</font></i>
<a name="34" href="#34">34</a> <font color="#329900"><i> * nor may "Apache" appear in their names without prior written</font></i>
<a name="35" href="#35">35</a> <font color="#329900"><i> * permission of the Apache Group.</font></i>
<a name="36" href="#36">36</a> <font color="#329900"><i> *</font></i>
<a name="37" href="#37">37</a> <font color="#329900"><i> * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED</font></i>
<a name="38" href="#38">38</a> <font color="#329900"><i> * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES</font></i>
<a name="39" href="#39">39</a> <font color="#329900"><i> * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE</font></i>
<a name="40" href="#40">40</a> <font color="#329900"><i> * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR</font></i>
<a name="41" href="#41">41</a> <font color="#329900"><i> * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,</font></i>
<a name="42" href="#42">42</a> <font color="#329900"><i> * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT</font></i>
<a name="43" href="#43">43</a> <font color="#329900"><i> * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF</font></i>
<a name="44" href="#44">44</a> <font color="#329900"><i> * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND</font></i>
<a name="45" href="#45">45</a> <font color="#329900"><i> * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,</font></i>
<a name="46" href="#46">46</a> <font color="#329900"><i> * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT</font></i>
<a name="47" href="#47">47</a> <font color="#329900"><i> * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF</font></i>
<a name="48" href="#48">48</a> <font color="#329900"><i> * SUCH DAMAGE.</font></i>
<a name="49" href="#49">49</a> <font color="#329900"><i> * ====================================================================</font></i>
<a name="50" href="#50">50</a> <font color="#329900"><i> *</font></i>
<a name="51" href="#51">51</a> <font color="#329900"><i> * This software consists of voluntary contributions made by many</font></i>
<a name="52" href="#52">52</a> <font color="#329900"><i> * individuals on behalf of the Apache Software Foundation. For more</font></i>
<a name="53" href="#53">53</a> <font color="#329900"><i> * information on the Apache Software Foundation, please see</font></i>
<a name="54" href="#54">54</a> <font color="#329900"><i> * <<a href="http://www.apache.org/>" target="alexandria_uri">http://www.apache.org/></a>;.</font></i>
<a name="55" href="#55">55</a> <font color="#329900"><i> *</font></i>
<a name="56" href="#56">56</a> <font color="#329900"><i> * [Additional notices, if required by prior licensing conditions]</font></i>
<a name="57" href="#57">57</a> <font color="#329900"><i> *</font></i>
<a name="58" href="#58">58</a> <font color="#329900"><i> */</font></i>
<a name="59" href="#59">59</a>
<a name="60" href="#60">60</a> <b>package</b> <a href="../../../../../org/apache/commons/latka/validators/index.html">org.apache.commons.latka.validators</a>;
<a name="61" href="#61">61</a>
<a name="62" href="#62">62</a> <b>import</b> <a href="../../../../../org/apache/commons/latka/index.html">org.apache.commons.latka</a>.<a href="../../../../../org/apache/commons/latka/Validator.html">Validator</a>;
<a name="63" href="#63">63</a> <b>import</b> <a href="../../../../../org/apache/commons/latka/index.html">org.apache.commons.latka</a>.<a href="../../../../../org/apache/commons/latka/ValidationException.html">ValidationException</a>;
<a name="64" href="#64">64</a>
<a name="65" href="#65">65</a> <b>import</b> <a href="../../../../../org/apache/commons/latka/http/index.html">org.apache.commons.latka.http</a>.<a href="../../../../../org/apache/commons/latka/http/Request.html">Request</a>;
<a name="66" href="#66">66</a> <b>import</b> <a href="../../../../../org/apache/commons/latka/http/index.html">org.apache.commons.latka.http</a>.<a href="../../../../../org/apache/commons/latka/http/Response.html">Response</a>;
<a name="67" href="#67">67</a>
<a name="68" href="#68">68</a> <b>import</b> java.text.MessageFormat;
<a name="69" href="#69">69</a>
<a name="70" href="#70">70</a> <b>public</b> <b>class</b> <a href="../../../../../org/apache/commons/latka/validators/MaxRequestTimeValidator.html">MaxRequestTimeValidator</a> <b>extends</b> <a href="../../../../../org/apache/commons/latka/validators/BaseValidator.html">BaseValidator</a> implements <a href="../../../../../org/apache/commons/latka/Validator.html">Validator</a> {
<a name="71" href="#71">71</a>
<a name="72" href="#72">72</a> <font color="#329900"><i>// --------------------------------------------------------------- Attributes</font></i>
<a name="73" href="#73">73</a>
<a name="74" href="#74">74</a> <b>protected</b> <b>int</b> _millis = 30000; <font color="#329900"><i>// shouldn't this be long?</font></i>
<a name="75" href="#75">75</a>
<a name="76" href="#76">76</a> <b>protected</b> <b>static</b> <b>final</b> MessageFormat MESSAGE = <b>new</b> MessageFormat(<font color="#000099">"Expected maximum response time of \"{0,number,integer}\" millis, but took at least \"{1,number,integer}\" millis."</font>);
<a name="77" href="#77">77</a>
<a name="78" href="#78">78</a> <font color="#329900"><i>// ------------------------------------------------------------- Constructors</font></i>
<a name="79" href="#79">79</a>
<a name="80" href="#80">80</a> <b>public</b> <a href="../../../../../org/apache/commons/latka/validators/MaxRequestTimeValidator.html">MaxRequestTimeValidator</a>() {
<a name="81" href="#81">81</a> <b>this</b>(<b>null</b>,30000);
<a name="82" href="#82">82</a> }
<a name="83" href="#83">83</a>
<a name="84" href="#84">84</a> <b>public</b> <a href="../../../../../org/apache/commons/latka/validators/MaxRequestTimeValidator.html">MaxRequestTimeValidator</a>(String label) {
<a name="85" href="#85">85</a> <b>this</b>(label,30000);
<a name="86" href="#86">86</a> }
<a name="87" href="#87">87</a>
<a name="88" href="#88">88</a> <b>public</b> <a href="../../../../../org/apache/commons/latka/validators/MaxRequestTimeValidator.html">MaxRequestTimeValidator</a>(String label, <b>int</b> millis) {
<a name="89" href="#89">89</a> <b>super</b>(label);
<a name="90" href="#90">90</a> _millis = millis;
<a name="91" href="#91">91</a> }
<a name="92" href="#92">92</a>
<a name="93" href="#93">93</a> <font color="#329900"><i>// ------------------------------------------------------------------ Methods</font></i>
<a name="94" href="#94">94</a>
<a name="95" href="#95">95</a> <b>public</b> <b>void</b> setMaxMillis(<b>int</b> millis) {
<a name="96" href="#96">96</a> _millis = millis;
<a name="97" href="#97">97</a> }
<a name="98" href="#98">98</a>
<a name="99" href="#99">99</a> <b>public</b> <b>void</b> validate(<a href="../../../../../org/apache/commons/latka/http/Response.html">Response</a> response) throws ValidationException {
<a name="100" href="#100">100</a> <a href="../../../../../org/apache/commons/latka/http/Request.html">Request</a> request = response.getRequest();
<a name="101" href="#101">101</a>
<a name="102" href="#102">102</a> <b>if</b> (request.getRequestTiming() > _millis) {
<a name="103" href="#103">103</a> fail(MESSAGE.format(<b>new</b> Object[] { <b>new</b> Integer(_millis), <b>new</b> Integer(request.getRequestTiming()) }).toString());
<a name="104" href="#104">104</a> }
<a name="105" href="#105">105</a> }
<a name="106" href="#106">106</a>
<a name="107" href="#107">107</a> }
</pre>
<hr><center>This page automatically generated by Maven</center></body>
</html>
1.1 jakarta-commons/docs/latka/xref/java/org/apache/commons/latka/validators/MaxRequestTimeHandler.html
Index: MaxRequestTimeHandler.html
===================================================================
<html>
<body bgcolor="white">
<pre>
<table bgcolor="#FFFFCC" cellpadding="0" cellspacing="0" border="0" width="100%"><a href="../../../../../../../apidocs/org/apache/commons/latka/validators/MaxRequestTimeHandler.html">View Javadoc</a></table>
<a name="1" href="#1">1</a> <font color="#329900"><i>/*</font></i>
<a name="2" href="#2">2</a> <font color="#329900"><i> * ====================================================================</font></i>
<a name="3" href="#3">3</a> <font color="#329900"><i> *</font></i>
<a name="4" href="#4">4</a> <font color="#329900"><i> * The Apache Software License, Version 1.1</font></i>
<a name="5" href="#5">5</a> <font color="#329900"><i> *</font></i>
<a name="6" href="#6">6</a> <font color="#329900"><i> * Copyright (c) 1999 The Apache Software Foundation. All rights </font></i>
<a name="7" href="#7">7</a> <font color="#329900"><i> * reserved.</font></i>
<a name="8" href="#8">8</a> <font color="#329900"><i> *</font></i>
<a name="9" href="#9">9</a> <font color="#329900"><i> * Redistribution and use in source and binary forms, with or without</font></i>
<a name="10" href="#10">10</a> <font color="#329900"><i> * modification, are permitted provided that the following conditions</font></i>
<a name="11" href="#11">11</a> <font color="#329900"><i> * are met:</font></i>
<a name="12" href="#12">12</a> <font color="#329900"><i> *</font></i>
<a name="13" href="#13">13</a> <font color="#329900"><i> * 1. Redistributions of source code must retain the above copyright</font></i>
<a name="14" href="#14">14</a> <font color="#329900"><i> * notice, this list of conditions and the following disclaimer. </font></i>
<a name="15" href="#15">15</a> <font color="#329900"><i> *</font></i>
<a name="16" href="#16">16</a> <font color="#329900"><i> * 2. Redistributions in binary form must reproduce the above copyright</font></i>
<a name="17" href="#17">17</a> <font color="#329900"><i> * notice, this list of conditions and the following disclaimer in</font></i>
<a name="18" href="#18">18</a> <font color="#329900"><i> * the documentation and/or other materials provided with the</font></i>
<a name="19" href="#19">19</a> <font color="#329900"><i> * distribution.</font></i>
<a name="20" href="#20">20</a> <font color="#329900"><i> *</font></i>
<a name="21" href="#21">21</a> <font color="#329900"><i> * 3. The end-user documentation included with the redistribution, if</font></i>
<a name="22" href="#22">22</a> <font color="#329900"><i> * any, must include the following acknowlegement: </font></i>
<a name="23" href="#23">23</a> <font color="#329900"><i> * "This product includes software developed by the </font></i>
<a name="24" href="#24">24</a> <font color="#329900"><i> * Apache Software Foundation (<a href="http://www.apache.org/" target="alexandria_uri">http://www.apache.org/</a>)."</font></i>
<a name="25" href="#25">25</a> <font color="#329900"><i> * Alternately, this acknowlegement may appear in the software itself,</font></i>
<a name="26" href="#26">26</a> <font color="#329900"><i> * if and wherever such third-party acknowlegements normally appear.</font></i>
<a name="27" href="#27">27</a> <font color="#329900"><i> *</font></i>
<a name="28" href="#28">28</a> <font color="#329900"><i> * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software</font></i>
<a name="29" href="#29">29</a> <font color="#329900"><i> * Foundation" must not be used to endorse or promote products derived</font></i>
<a name="30" href="#30">30</a> <font color="#329900"><i> * from this software without prior written permission. For written </font></i>
<a name="31" href="#31">31</a> <font color="#329900"><i> * permission, please contact apache@apache.org.</font></i>
<a name="32" href="#32">32</a> <font color="#329900"><i> *</font></i>
<a name="33" href="#33">33</a> <font color="#329900"><i> * 5. Products derived from this software may not be called "Apache"</font></i>
<a name="34" href="#34">34</a> <font color="#329900"><i> * nor may "Apache" appear in their names without prior written</font></i>
<a name="35" href="#35">35</a> <font color="#329900"><i> * permission of the Apache Group.</font></i>
<a name="36" href="#36">36</a> <font color="#329900"><i> *</font></i>
<a name="37" href="#37">37</a> <font color="#329900"><i> * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED</font></i>
<a name="38" href="#38">38</a> <font color="#329900"><i> * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES</font></i>
<a name="39" href="#39">39</a> <font color="#329900"><i> * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE</font></i>
<a name="40" href="#40">40</a> <font color="#329900"><i> * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR</font></i>
<a name="41" href="#41">41</a> <font color="#329900"><i> * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,</font></i>
<a name="42" href="#42">42</a> <font color="#329900"><i> * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT</font></i>
<a name="43" href="#43">43</a> <font color="#329900"><i> * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF</font></i>
<a name="44" href="#44">44</a> <font color="#329900"><i> * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND</font></i>
<a name="45" href="#45">45</a> <font color="#329900"><i> * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,</font></i>
<a name="46" href="#46">46</a> <font color="#329900"><i> * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT</font></i>
<a name="47" href="#47">47</a> <font color="#329900"><i> * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF</font></i>
<a name="48" href="#48">48</a> <font color="#329900"><i> * SUCH DAMAGE.</font></i>
<a name="49" href="#49">49</a> <font color="#329900"><i> * ====================================================================</font></i>
<a name="50" href="#50">50</a> <font color="#329900"><i> *</font></i>
<a name="51" href="#51">51</a> <font color="#329900"><i> * This software consists of voluntary contributions made by many</font></i>
<a name="52" href="#52">52</a> <font color="#329900"><i> * individuals on behalf of the Apache Software Foundation. For more</font></i>
<a name="53" href="#53">53</a> <font color="#329900"><i> * information on the Apache Software Foundation, please see</font></i>
<a name="54" href="#54">54</a> <font color="#329900"><i> * <<a href="http://www.apache.org/>" target="alexandria_uri">http://www.apache.org/></a>;.</font></i>
<a name="55" href="#55">55</a> <font color="#329900"><i> *</font></i>
<a name="56" href="#56">56</a> <font color="#329900"><i> * [Additional notices, if required by prior licensing conditions]</font></i>
<a name="57" href="#57">57</a> <font color="#329900"><i> *</font></i>
<a name="58" href="#58">58</a> <font color="#329900"><i> */</font></i>
<a name="59" href="#59">59</a>
<a name="60" href="#60">60</a> <b>package</b> <a href="../../../../../org/apache/commons/latka/validators/index.html">org.apache.commons.latka.validators</a>;
<a name="61" href="#61">61</a>
<a name="62" href="#62">62</a> <b>import</b> <a href="../../../../../org/apache/commons/latka/xml/index.html">org.apache.commons.latka.xml</a>.<a href="../../../../../org/apache/commons/latka/xml/ValidationHandler.html">ValidationHandler</a>;
<a name="63" href="#63">63</a>
<a name="64" href="#64">64</a> <b>import</b> org.xml.sax.Attributes;
<a name="65" href="#65">65</a> <b>import</b> org.xml.sax.SAXException;
<a name="66" href="#66">66</a>
<a name="67" href="#67">67</a> <b>public</b> <b>class</b> <a href="../../../../../org/apache/commons/latka/validators/MaxRequestTimeHandler.html">MaxRequestTimeHandler</a> <b>extends</b> <a href="../../../../../org/apache/commons/latka/xml/ValidationHandler.html">ValidationHandler</a> {
<a name="68" href="#68">68</a>
<a name="69" href="#69">69</a> <b>public</b> <b>void</b> startElement(String uri, String localName,
<a name="70" href="#70">70</a> String qName, Attributes atts)
<a name="71" href="#71">71</a> throws SAXException {
<a name="72" href="#72">72</a>
<a name="73" href="#73">73</a> <a href="../../../../../org/apache/commons/latka/validators/MaxRequestTimeValidator.html">MaxRequestTimeValidator</a> validator =
<a name="74" href="#74">74</a> <b>new</b> <a href="../../../../../org/apache/commons/latka/validators/MaxRequestTimeValidator.html">MaxRequestTimeValidator</a>(atts.getValue(<font color="#000099">"label"</font>));
<a name="75" href="#75">75</a>
<a name="76" href="#76">76</a> String maxMillis = atts.getValue(<font color="#000099">"millis"</font>);
<a name="77" href="#77">77</a> <b>if</b> (maxMillis != <b>null</b>) {
<a name="78" href="#78">78</a> validator.setMaxMillis(Integer.parseInt(maxMillis));
<a name="79" href="#79">79</a> }
<a name="80" href="#80">80</a>
<a name="81" href="#81">81</a> validate(validator);
<a name="82" href="#82">82</a>
<a name="83" href="#83">83</a> }
<a name="84" href="#84">84</a>
<a name="85" href="#85">85</a> }
</pre>
<hr><center>This page automatically generated by Maven</center></body>
</html>
1.1 jakarta-commons/docs/latka/xref/java/org/apache/commons/latka/validators/index.html
Index: index.html
===================================================================
<html>
<body bgcolor="white">
<a href="../">[parent]</a>
<hr>
<table width="100%">
<tr>
<td><b>Name</b></td>
<td><b>Size</b></td>
<td><b>Last Modified</b></td>
</tr>
<tr valign="middle"><td valign="middle" NOWRAP><img src="./file.gif" valign="middle" border="0"> <a href="BaseValidator.html">BaseValidator.java</a></td><td valign="middle" NOWRAP>11984 (in bytes) </td><td valign="middle" NOWRAP>1/04/2002</td></tr>
<tr valign="middle"><td valign="middle" NOWRAP><img src="./file.gif" valign="middle" border="0"> <a href="ByteLengthHandler.html">ByteLengthHandler.java</a></td><td valign="middle" NOWRAP>9763 (in bytes) </td><td valign="middle" NOWRAP>1/04/2002</td></tr>
<tr valign="middle"><td valign="middle" NOWRAP><img src="./file.gif" valign="middle" border="0"> <a href="ByteLengthValidator.html">ByteLengthValidator.java</a></td><td valign="middle" NOWRAP>13755 (in bytes) </td><td valign="middle" NOWRAP>1/04/2002</td></tr>
<tr valign="middle"><td valign="middle" NOWRAP><img src="./file.gif" valign="middle" border="0"> <a href="CookieHandler.html">CookieHandler.java</a></td><td valign="middle" NOWRAP>9680 (in bytes) </td><td valign="middle" NOWRAP>1/04/2002</td></tr>
<tr valign="middle"><td valign="middle" NOWRAP><img src="./file.gif" valign="middle" border="0"> <a href="CookieValidator.html">CookieValidator.java</a></td><td valign="middle" NOWRAP>16832 (in bytes) </td><td valign="middle" NOWRAP>1/04/2002</td></tr>
<tr valign="middle"><td valign="middle" NOWRAP><img src="./file.gif" valign="middle" border="0"> <a href="GoldenFileValidator.html">GoldenFileValidator.java</a></td><td valign="middle" NOWRAP>17453 (in bytes) </td><td valign="middle" NOWRAP>1/04/2002</td></tr>
<tr valign="middle"><td valign="middle" NOWRAP><img src="./file.gif" valign="middle" border="0"> <a href="MaxRequestTimeHandler.html">MaxRequestTimeHandler.java</a></td><td valign="middle" NOWRAP>9446 (in bytes) </td><td valign="middle" NOWRAP>1/04/2002</td></tr>
<tr valign="middle"><td valign="middle" NOWRAP><img src="./file.gif" valign="middle" border="0"> <a href="MaxRequestTimeValidator.html">MaxRequestTimeValidator.java</a></td><td valign="middle" NOWRAP>12008 (in bytes) </td><td valign="middle" NOWRAP>1/04/2002</td></tr>
<tr valign="middle"><td valign="middle" NOWRAP><img src="./file.gif" valign="middle" border="0"> <a href="RegexpHandler.html">RegexpHandler.java</a></td><td valign="middle" NOWRAP>9900 (in bytes) </td><td valign="middle" NOWRAP>1/04/2002</td></tr>
<tr valign="middle"><td valign="middle" NOWRAP><img src="./file.gif" valign="middle" border="0"> <a href="RegexpValidator.html">RegexpValidator.java</a></td><td valign="middle" NOWRAP>14580 (in bytes) </td><td valign="middle" NOWRAP>1/04/2002</td></tr>
<tr valign="middle"><td valign="middle" NOWRAP><img src="./file.gif" valign="middle" border="0"> <a href="StatusCodeHandler.html">StatusCodeHandler.java</a></td><td valign="middle" NOWRAP>9420 (in bytes) </td><td valign="middle" NOWRAP>1/04/2002</td></tr>
<tr valign="middle"><td valign="middle" NOWRAP><img src="./file.gif" valign="middle" border="0"> <a href="StatusCodeValidator.html">StatusCodeValidator.java</a></td><td valign="middle" NOWRAP>12672 (in bytes) </td><td valign="middle" NOWRAP>1/04/2002</td></tr>
<tr valign="middle"><td valign="middle" NOWRAP><img src="./file.gif" valign="middle" border="0"> <a href="XPathHandler.html">XPathHandler.java</a></td><td valign="middle" NOWRAP>10299 (in bytes) </td><td valign="middle" NOWRAP>1/04/2002</td></tr>
<tr valign="middle"><td valign="middle" NOWRAP><img src="./file.gif" valign="middle" border="0"> <a href="XPathValidator.html">XPathValidator.java</a></td><td valign="middle" NOWRAP>36351 (in bytes) </td><td valign="middle" NOWRAP>1/04/2002</td></tr>
</table>
<hr>
<center>This page automatically generated by Maven</center>
</body>
</html>
1.1 jakarta-commons/docs/latka/xref/java/org/apache/commons/latka/validators/GoldenFileValidator.html
Index: GoldenFileValidator.html
===================================================================
<html>
<body bgcolor="white">
<pre>
<table bgcolor="#FFFFCC" cellpadding="0" cellspacing="0" border="0" width="100%"><a href="../../../../../../../apidocs/org/apache/commons/latka/validators/GoldenFileValidator.html">View Javadoc</a></table>
<a name="1" href="#1">1</a> <font color="#329900"><i>/*</font></i>
<a name="2" href="#2">2</a> <font color="#329900"><i> * ====================================================================</font></i>
<a name="3" href="#3">3</a> <font color="#329900"><i> *</font></i>
<a name="4" href="#4">4</a> <font color="#329900"><i> * The Apache Software License, Version 1.1</font></i>
<a name="5" href="#5">5</a> <font color="#329900"><i> *</font></i>
<a name="6" href="#6">6</a> <font color="#329900"><i> * Copyright (c) 1999 The Apache Software Foundation. All rights </font></i>
<a name="7" href="#7">7</a> <font color="#329900"><i> * reserved.</font></i>
<a name="8" href="#8">8</a> <font color="#329900"><i> *</font></i>
<a name="9" href="#9">9</a> <font color="#329900"><i> * Redistribution and use in source and binary forms, with or without</font></i>
<a name="10" href="#10">10</a> <font color="#329900"><i> * modification, are permitted provided that the following conditions</font></i>
<a name="11" href="#11">11</a> <font color="#329900"><i> * are met:</font></i>
<a name="12" href="#12">12</a> <font color="#329900"><i> *</font></i>
<a name="13" href="#13">13</a> <font color="#329900"><i> * 1. Redistributions of source code must retain the above copyright</font></i>
<a name="14" href="#14">14</a> <font color="#329900"><i> * notice, this list of conditions and the following disclaimer. </font></i>
<a name="15" href="#15">15</a> <font color="#329900"><i> *</font></i>
<a name="16" href="#16">16</a> <font color="#329900"><i> * 2. Redistributions in binary form must reproduce the above copyright</font></i>
<a name="17" href="#17">17</a> <font color="#329900"><i> * notice, this list of conditions and the following disclaimer in</font></i>
<a name="18" href="#18">18</a> <font color="#329900"><i> * the documentation and/or other materials provided with the</font></i>
<a name="19" href="#19">19</a> <font color="#329900"><i> * distribution.</font></i>
<a name="20" href="#20">20</a> <font color="#329900"><i> *</font></i>
<a name="21" href="#21">21</a> <font color="#329900"><i> * 3. The end-user documentation included with the redistribution, if</font></i>
<a name="22" href="#22">22</a> <font color="#329900"><i> * any, must include the following acknowlegement: </font></i>
<a name="23" href="#23">23</a> <font color="#329900"><i> * "This product includes software developed by the </font></i>
<a name="24" href="#24">24</a> <font color="#329900"><i> * Apache Software Foundation (<a href="http://www.apache.org/" target="alexandria_uri">http://www.apache.org/</a>)."</font></i>
<a name="25" href="#25">25</a> <font color="#329900"><i> * Alternately, this acknowlegement may appear in the software itself,</font></i>
<a name="26" href="#26">26</a> <font color="#329900"><i> * if and wherever such third-party acknowlegements normally appear.</font></i>
<a name="27" href="#27">27</a> <font color="#329900"><i> *</font></i>
<a name="28" href="#28">28</a> <font color="#329900"><i> * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software</font></i>
<a name="29" href="#29">29</a> <font color="#329900"><i> * Foundation" must not be used to endorse or promote products derived</font></i>
<a name="30" href="#30">30</a> <font color="#329900"><i> * from this software without prior written permission. For written </font></i>
<a name="31" href="#31">31</a> <font color="#329900"><i> * permission, please contact apache@apache.org.</font></i>
<a name="32" href="#32">32</a> <font color="#329900"><i> *</font></i>
<a name="33" href="#33">33</a> <font color="#329900"><i> * 5. Products derived from this software may not be called "Apache"</font></i>
<a name="34" href="#34">34</a> <font color="#329900"><i> * nor may "Apache" appear in their names without prior written</font></i>
<a name="35" href="#35">35</a> <font color="#329900"><i> * permission of the Apache Group.</font></i>
<a name="36" href="#36">36</a> <font color="#329900"><i> *</font></i>
<a name="37" href="#37">37</a> <font color="#329900"><i> * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED</font></i>
<a name="38" href="#38">38</a> <font color="#329900"><i> * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES</font></i>
<a name="39" href="#39">39</a> <font color="#329900"><i> * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE</font></i>
<a name="40" href="#40">40</a> <font color="#329900"><i> * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR</font></i>
<a name="41" href="#41">41</a> <font color="#329900"><i> * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,</font></i>
<a name="42" href="#42">42</a> <font color="#329900"><i> * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT</font></i>
<a name="43" href="#43">43</a> <font color="#329900"><i> * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF</font></i>
<a name="44" href="#44">44</a> <font color="#329900"><i> * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND</font></i>
<a name="45" href="#45">45</a> <font color="#329900"><i> * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,</font></i>
<a name="46" href="#46">46</a> <font color="#329900"><i> * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT</font></i>
<a name="47" href="#47">47</a> <font color="#329900"><i> * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF</font></i>
<a name="48" href="#48">48</a> <font color="#329900"><i> * SUCH DAMAGE.</font></i>
<a name="49" href="#49">49</a> <font color="#329900"><i> * ====================================================================</font></i>
<a name="50" href="#50">50</a> <font color="#329900"><i> *</font></i>
<a name="51" href="#51">51</a> <font color="#329900"><i> * This software consists of voluntary contributions made by many</font></i>
<a name="52" href="#52">52</a> <font color="#329900"><i> * individuals on behalf of the Apache Software Foundation. For more</font></i>
<a name="53" href="#53">53</a> <font color="#329900"><i> * information on the Apache Software Foundation, please see</font></i>
<a name="54" href="#54">54</a> <font color="#329900"><i> * <<a href="http://www.apache.org/>" target="alexandria_uri">http://www.apache.org/></a>;.</font></i>
<a name="55" href="#55">55</a> <font color="#329900"><i> *</font></i>
<a name="56" href="#56">56</a> <font color="#329900"><i> * [Additional notices, if required by prior licensing conditions]</font></i>
<a name="57" href="#57">57</a> <font color="#329900"><i> *</font></i>
<a name="58" href="#58">58</a> <font color="#329900"><i> */</font></i>
<a name="59" href="#59">59</a> <b>package</b> <a href="../../../../../org/apache/commons/latka/validators/index.html">org.apache.commons.latka.validators</a>;
<a name="60" href="#60">60</a>
<a name="61" href="#61">61</a> <b>import</b> java.io.File;
<a name="62" href="#62">62</a> <b>import</b> java.io.FileReader;
<a name="63" href="#63">63</a> <b>import</b> java.io.IOException;
<a name="64" href="#64">64</a>
<a name="65" href="#65">65</a> <b>import</b> java.util.StringTokenizer;
<a name="66" href="#66">66</a>
<a name="67" href="#67">67</a> <b>import</b> <a href="../../../../../org/apache/commons/latka/index.html">org.apache.commons.latka</a>.<a href="../../../../../org/apache/commons/latka/Validator.html">Validator</a>;
<a name="68" href="#68">68</a> <b>import</b> <a href="../../../../../org/apache/commons/latka/index.html">org.apache.commons.latka</a>.<a href="../../../../../org/apache/commons/latka/ValidationException.html">ValidationException</a>;
<a name="69" href="#69">69</a> <b>import</b> <a href="../../../../../org/apache/commons/latka/http/index.html">org.apache.commons.latka.http</a>.<a href="../../../../../org/apache/commons/latka/http/Response.html">Response</a>;
<a name="70" href="#70">70</a>
<a name="71" href="#71">71</a> <font color="#AA0000"><i>/**<font color="#AA0000"><i>* Compare the response with a golden</font></i></font></i>
<a name="72" href="#72">72</a> <font color="#AA0000"><i> file. Right now this is a proof</font></i>
<a name="73" href="#73">73</a> <font color="#AA0000"><i> of concept class; we should extend it to support</font></i>
<a name="74" href="#74">74</a> <font color="#AA0000"><i> more than just files, I think. Also, maybe</font></i>
<a name="75" href="#75">75</a> <font color="#AA0000"><i> golden files should be more than just text.</font></i>
<a name="76" href="#76">76</a> <font color="#AA0000"><i>*/</font></i>
<a name="77" href="#77">77</a> <b>public</b> <b>class</b> <a href="../../../../../org/apache/commons/latka/validators/GoldenFileValidator.html">GoldenFileValidator</a> <b>extends</b> <a href="../../../../../org/apache/commons/latka/validators/BaseValidator.html">BaseValidator</a>
<a name="78" href="#78">78</a> implements <a href="../../../../../org/apache/commons/latka/Validator.html">Validator</a> {
<a name="79" href="#79">79</a>
<a name="80" href="#80">80</a> <b>protected</b> File _goldFile = <b>null</b>;
<a name="81" href="#81">81</a> <b>protected</b> <b>boolean</b> _ignoreWhitespace=false;
<a name="82" href="#82">82</a> <b>protected</b> <b>static</b> String TRUE_MESSAGE = <font color="#000099">"EXPECTED TO MATCH GOLDEN FILE: "</font>;
<a name="83" href="#83">83</a> <b>protected</b> StringBuffer _matchLog = <b>new</b> StringBuffer();
<a name="84" href="#84">84</a>
<a name="85" href="#85">85</a> <b>public</b> <a href="../../../../../org/apache/commons/latka/validators/GoldenFileValidator.html">GoldenFileValidator</a>(File goldenFile) {
<a name="86" href="#86">86</a> <b>this</b>(<b>null</b>,goldenFile);
<a name="87" href="#87">87</a> }
<a name="88" href="#88">88</a>
<a name="89" href="#89">89</a> <b>public</b> <a href="../../../../../org/apache/commons/latka/validators/GoldenFileValidator.html">GoldenFileValidator</a>(String label, File goldenFile) {
<a name="90" href="#90">90</a> <b>super</b>(label);
<a name="91" href="#91">91</a> _goldFile = goldenFile;
<a name="92" href="#92">92</a> }
<a name="93" href="#93">93</a>
<a name="94" href="#94">94</a> <b>public</b> <b>void</b> setIgnoreWhitespace(<b>boolean</b> ignoreWhitespace) {
<a name="95" href="#95">95</a> _ignoreWhitespace = ignoreWhitespace;
<a name="96" href="#96">96</a> }
<a name="97" href="#97">97</a>
<a name="98" href="#98">98</a> <b>public</b> <b>void</b> validate(<a href="../../../../../org/apache/commons/latka/http/Response.html">Response</a> response)
<a name="99" href="#99">99</a> throws <a href="../../../../../org/apache/commons/latka/ValidationException.html">ValidationException</a> {
<a name="100" href="#100">100</a>
<a name="101" href="#101">101</a> String goldFileString = <b>null</b>;
<a name="102" href="#102">102</a>
<a name="103" href="#103">103</a> <b>try</b> {
<a name="104" href="#104">104</a> FileReader reader = <b>new</b> FileReader(_goldFile);
<a name="105" href="#105">105</a>
<a name="106" href="#106">106</a> StringBuffer buf = <b>new</b> StringBuffer();
<a name="107" href="#107">107</a>
<a name="108" href="#108">108</a> <b>while</b> (<b>true</b>) {
<a name="109" href="#109">109</a> <b>int</b> ch = reader.read();
<a name="110" href="#110">110</a> <b>if</b> (ch < 0) {
<a name="111" href="#111">111</a> <b>break</b>;
<a name="112" href="#112">112</a> }
<a name="113" href="#113">113</a> buf.append((<b>char</b>) ch);
<a name="114" href="#114">114</a> }
<a name="115" href="#115">115</a>
<a name="116" href="#116">116</a> goldFileString = buf.toString();
<a name="117" href="#117">117</a> } <b>catch</b> (IOException e) {
<a name="118" href="#118">118</a> fail(e.toString());
<a name="119" href="#119">119</a> }
<a name="120" href="#120">120</a>
<a name="121" href="#121">121</a> <font color="#329900"><i>// Compare the results and set the status</font></i>
<a name="122" href="#122">122</a> <b>boolean</b> cmp=<b>true</b>;
<a name="123" href="#123">123</a>
<a name="124" href="#124">124</a> <b>if</b>(_ignoreWhitespace) {
<a name="125" href="#125">125</a> cmp=compareWeak(response.getResource(), goldFileString );
<a name="126" href="#126">126</a> } <b>else</b> {
<a name="127" href="#127">127</a> cmp=compare(response.getResource(), goldFileString );
<a name="128" href="#128">128</a> }
<a name="129" href="#129">129</a>
<a name="130" href="#130">130</a> <b>if</b> (cmp == false) {
<a name="131" href="#131">131</a> StringBuffer buf = <b>new</b> StringBuffer();
<a name="132" href="#132">132</a> buf.append(TRUE_MESSAGE);
<a name="133" href="#133">133</a> buf.append(_goldFile);
<a name="134" href="#134">134</a> buf.append(<font color="#000099">"\n"</font>);
<a name="135" href="#135">135</a> buf.append(_matchLog);
<a name="136" href="#136">136</a> fail(buf.toString());
<a name="137" href="#137">137</a> }
<a name="138" href="#138">138</a>
<a name="139" href="#139">139</a>
<a name="140" href="#140">140</a> }
<a name="141" href="#141">141</a>
<a name="142" href="#142">142</a> <font color="#329900"><i>// Compare the actual result and the expected result.</font></i>
<a name="143" href="#143">143</a> <b>protected</b> <b>boolean</b> compare(String str1, String str2) {
<a name="144" href="#144">144</a> <b>if</b> ( str1==<b>null</b> || str2==<b>null</b>) <b>return</b> false;
<a name="145" href="#145">145</a> <b>if</b> ( str1.length() != str2.length() ) {
<a name="146" href="#146">146</a> log(<font color="#000099">"Wrong size "</font> + str1.length() +<font color="#000099">" "</font> + str2.length() );
<a name="147" href="#147">147</a> <b>return</b> false;
<a name="148" href="#148">148</a> }
<a name="149" href="#149">149</a>
<a name="150" href="#150">150</a> <b>for</b> (<b>int</b> i=0; i<str1.length() ; i++ ) {
<a name="151" href="#151">151</a> <b>if</b> (str1.charAt( i ) != str2.charAt( i ) ) {
<a name="152" href="#152">152</a> log(<font color="#000099">"Error at "</font> + i + <font color="#000099">" "</font> + str1.charAt(1) +
<a name="153" href="#153">153</a> str2.charAt(i));
<a name="154" href="#154">154</a> <b>return</b> false;
<a name="155" href="#155">155</a> }
<a name="156" href="#156">156</a> }
<a name="157" href="#157">157</a> <b>return</b> <b>true</b>;
<a name="158" href="#158">158</a> }
<a name="159" href="#159">159</a>
<a name="160" href="#160">160</a> <font color="#329900"><i>// Compare the actual result and the expected result.</font></i>
<a name="161" href="#161">161</a> <font color="#329900"><i>// Original compare - ignores whitespace ( because most</font></i>
<a name="162" href="#162">162</a> <font color="#329900"><i>// golden files are wrong !)</font></i>
<a name="163" href="#163">163</a> <b>protected</b> <b>boolean</b> compareWeak(String str1, String str2) {
<a name="164" href="#164">164</a> <b>if</b> ( str1==<b>null</b> || str2==<b>null</b>) <b>return</b> false;
<a name="165" href="#165">165</a>
<a name="166" href="#166">166</a> StringTokenizer st1=<b>new</b> StringTokenizer(str1);
<a name="167" href="#167">167</a> StringTokenizer st2=<b>new</b> StringTokenizer(str2);
<a name="168" href="#168">168</a>
<a name="169" href="#169">169</a> <b>while</b> (st1.hasMoreTokens() && st2.hasMoreTokens()) {
<a name="170" href="#170">170</a> String tok1 = st1.nextToken();
<a name="171" href="#171">171</a> String tok2 = st2.nextToken();
<a name="172" href="#172">172</a> <b>if</b> (!tok1.equals(tok2)) {
<a name="173" href="#173">173</a> log(<font color="#000099">"\tFAIL*** : Live token = "</font> + tok1
<a name="174" href="#174">174</a> + <font color="#000099">", did not match golden file token = "</font> + tok2);
<a name="175" href="#175">175</a> <b>return</b> false;
<a name="176" href="#176">176</a> }
<a name="177" href="#177">177</a> }
<a name="178" href="#178">178</a>
<a name="179" href="#179">179</a> <b>if</b> (st1.hasMoreTokens() || st2.hasMoreTokens()) {
<a name="180" href="#180">180</a> <b>return</b> false;
<a name="181" href="#181">181</a> } <b>else</b> {
<a name="182" href="#182">182</a> <b>return</b> <b>true</b>;
<a name="183" href="#183">183</a> }
<a name="184" href="#184">184</a> }
<a name="185" href="#185">185</a>
<a name="186" href="#186">186</a> <b>protected</b> <b>void</b> log(String message) {
<a name="187" href="#187">187</a> _matchLog.append(message);
<a name="188" href="#188">188</a> }
<a name="189" href="#189">189</a>
<a name="190" href="#190">190</a> }
</pre>
<hr><center>This page automatically generated by Maven</center></body>
</html>
1.1 jakarta-commons/docs/latka/xref/java/org/apache/commons/latka/validators/CookieValidator.html
Index: CookieValidator.html
===================================================================
<html>
<body bgcolor="white">
<pre>
<table bgcolor="#FFFFCC" cellpadding="0" cellspacing="0" border="0" width="100%"><a href="../../../../../../../apidocs/org/apache/commons/latka/validators/CookieValidator.html">View Javadoc</a></table>
<a name="1" href="#1">1</a> <font color="#329900"><i>/*</font></i>
<a name="2" href="#2">2</a> <font color="#329900"><i> * ====================================================================</font></i>
<a name="3" href="#3">3</a> <font color="#329900"><i> *</font></i>
<a name="4" href="#4">4</a> <font color="#329900"><i> * The Apache Software License, Version 1.1</font></i>
<a name="5" href="#5">5</a> <font color="#329900"><i> *</font></i>
<a name="6" href="#6">6</a> <font color="#329900"><i> * Copyright (c) 1999 The Apache Software Foundation. All rights </font></i>
<a name="7" href="#7">7</a> <font color="#329900"><i> * reserved.</font></i>
<a name="8" href="#8">8</a> <font color="#329900"><i> *</font></i>
<a name="9" href="#9">9</a> <font color="#329900"><i> * Redistribution and use in source and binary forms, with or without</font></i>
<a name="10" href="#10">10</a> <font color="#329900"><i> * modification, are permitted provided that the following conditions</font></i>
<a name="11" href="#11">11</a> <font color="#329900"><i> * are met:</font></i>
<a name="12" href="#12">12</a> <font color="#329900"><i> *</font></i>
<a name="13" href="#13">13</a> <font color="#329900"><i> * 1. Redistributions of source code must retain the above copyright</font></i>
<a name="14" href="#14">14</a> <font color="#329900"><i> * notice, this list of conditions and the following disclaimer. </font></i>
<a name="15" href="#15">15</a> <font color="#329900"><i> *</font></i>
<a name="16" href="#16">16</a> <font color="#329900"><i> * 2. Redistributions in binary form must reproduce the above copyright</font></i>
<a name="17" href="#17">17</a> <font color="#329900"><i> * notice, this list of conditions and the following disclaimer in</font></i>
<a name="18" href="#18">18</a> <font color="#329900"><i> * the documentation and/or other materials provided with the</font></i>
<a name="19" href="#19">19</a> <font color="#329900"><i> * distribution.</font></i>
<a name="20" href="#20">20</a> <font color="#329900"><i> *</font></i>
<a name="21" href="#21">21</a> <font color="#329900"><i> * 3. The end-user documentation included with the redistribution, if</font></i>
<a name="22" href="#22">22</a> <font color="#329900"><i> * any, must include the following acknowlegement: </font></i>
<a name="23" href="#23">23</a> <font color="#329900"><i> * "This product includes software developed by the </font></i>
<a name="24" href="#24">24</a> <font color="#329900"><i> * Apache Software Foundation (<a href="http://www.apache.org/" target="alexandria_uri">http://www.apache.org/</a>)."</font></i>
<a name="25" href="#25">25</a> <font color="#329900"><i> * Alternately, this acknowlegement may appear in the software itself,</font></i>
<a name="26" href="#26">26</a> <font color="#329900"><i> * if and wherever such third-party acknowlegements normally appear.</font></i>
<a name="27" href="#27">27</a> <font color="#329900"><i> *</font></i>
<a name="28" href="#28">28</a> <font color="#329900"><i> * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software</font></i>
<a name="29" href="#29">29</a> <font color="#329900"><i> * Foundation" must not be used to endorse or promote products derived</font></i>
<a name="30" href="#30">30</a> <font color="#329900"><i> * from this software without prior written permission. For written </font></i>
<a name="31" href="#31">31</a> <font color="#329900"><i> * permission, please contact apache@apache.org.</font></i>
<a name="32" href="#32">32</a> <font color="#329900"><i> *</font></i>
<a name="33" href="#33">33</a> <font color="#329900"><i> * 5. Products derived from this software may not be called "Apache"</font></i>
<a name="34" href="#34">34</a> <font color="#329900"><i> * nor may "Apache" appear in their names without prior written</font></i>
<a name="35" href="#35">35</a> <font color="#329900"><i> * permission of the Apache Group.</font></i>
<a name="36" href="#36">36</a> <font color="#329900"><i> *</font></i>
<a name="37" href="#37">37</a> <font color="#329900"><i> * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED</font></i>
<a name="38" href="#38">38</a> <font color="#329900"><i> * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES</font></i>
<a name="39" href="#39">39</a> <font color="#329900"><i> * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE</font></i>
<a name="40" href="#40">40</a> <font color="#329900"><i> * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR</font></i>
<a name="41" href="#41">41</a> <font color="#329900"><i> * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,</font></i>
<a name="42" href="#42">42</a> <font color="#329900"><i> * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT</font></i>
<a name="43" href="#43">43</a> <font color="#329900"><i> * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF</font></i>
<a name="44" href="#44">44</a> <font color="#329900"><i> * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND</font></i>
<a name="45" href="#45">45</a> <font color="#329900"><i> * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,</font></i>
<a name="46" href="#46">46</a> <font color="#329900"><i> * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT</font></i>
<a name="47" href="#47">47</a> <font color="#329900"><i> * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF</font></i>
<a name="48" href="#48">48</a> <font color="#329900"><i> * SUCH DAMAGE.</font></i>
<a name="49" href="#49">49</a> <font color="#329900"><i> * ====================================================================</font></i>
<a name="50" href="#50">50</a> <font color="#329900"><i> *</font></i>
<a name="51" href="#51">51</a> <font color="#329900"><i> * This software consists of voluntary contributions made by many</font></i>
<a name="52" href="#52">52</a> <font color="#329900"><i> * individuals on behalf of the Apache Software Foundation. For more</font></i>
<a name="53" href="#53">53</a> <font color="#329900"><i> * information on the Apache Software Foundation, please see</font></i>
<a name="54" href="#54">54</a> <font color="#329900"><i> * <<a href="http://www.apache.org/>" target="alexandria_uri">http://www.apache.org/></a>;.</font></i>
<a name="55" href="#55">55</a> <font color="#329900"><i> *</font></i>
<a name="56" href="#56">56</a> <font color="#329900"><i> * [Additional notices, if required by prior licensing conditions]</font></i>
<a name="57" href="#57">57</a> <font color="#329900"><i> *</font></i>
<a name="58" href="#58">58</a> <font color="#329900"><i> */</font></i>
<a name="59" href="#59">59</a>
<a name="60" href="#60">60</a> <b>package</b> <a href="../../../../../org/apache/commons/latka/validators/index.html">org.apache.commons.latka.validators</a>;
<a name="61" href="#61">61</a>
<a name="62" href="#62">62</a> <b>import</b> <a href="../../../../../org/apache/commons/latka/index.html">org.apache.commons.latka</a>.<a href="../../../../../org/apache/commons/latka/Validator.html">Validator</a>;
<a name="63" href="#63">63</a> <b>import</b> <a href="../../../../../org/apache/commons/latka/index.html">org.apache.commons.latka</a>.<a href="../../../../../org/apache/commons/latka/ValidationException.html">ValidationException</a>;
<a name="64" href="#64">64</a>
<a name="65" href="#65">65</a> <b>import</b> <a href="../../../../../org/apache/commons/latka/http/index.html">org.apache.commons.latka.http</a>.<a href="../../../../../org/apache/commons/latka/http/Session.html">Session</a>;
<a name="66" href="#66">66</a> <b>import</b> <a href="../../../../../org/apache/commons/latka/http/index.html">org.apache.commons.latka.http</a>.<a href="../../../../../org/apache/commons/latka/http/Response.html">Response</a>;
<a name="67" href="#67">67</a>
<a name="68" href="#68">68</a> <font color="#AA0000"><i>/**<font color="#AA0000"><i>*</font></i></font></i>
<a name="69" href="#69">69</a> <font color="#AA0000"><i> * CookieValidator validates cookie existence and/or value in an HTTP session.</font></i>
<a name="70" href="#70">70</a> <font color="#AA0000"><i> *</font></i>
<a name="71" href="#71">71</a> <font color="#AA0000"><i> * @author <a href="<a href="mailto:dsale@us.britannica.com" target="alexandria_uri">mailto:dsale@us.britannica.com</a>">Doug Sale</a></font></i>
<a name="72" href="#72">72</a> <font color="#AA0000"><i> * @author dIon Gillard</font></i>
<a name="73" href="#73">73</a> <font color="#AA0000"><i> * @version $Id: CookieValidator.html,v 1.1 2002/04/01 05:44:07 dion Exp $</font></i>
<a name="74" href="#74">74</a> <font color="#AA0000"><i> */</font></i>
<a name="75" href="#75">75</a> <b>public</b> <b>class</b> <a href="../../../../../org/apache/commons/latka/validators/CookieValidator.html">CookieValidator</a> <b>extends</b> <a href="../../../../../org/apache/commons/latka/validators/BaseValidator.html">BaseValidator</a> implements <a href="../../../../../org/apache/commons/latka/Validator.html">Validator</a> {
<a name="76" href="#76">76</a>
<a name="77" href="#77">77</a> <font color="#329900"><i>// --------------------------------------------------------------- Attributes</font></i>
<a name="78" href="#78">78</a>
<a name="79" href="#79">79</a> <b>protected</b> String _cookieValue = <b>null</b>;
<a name="80" href="#80">80</a> <b>protected</b> String _cookieName = <b>null</b>;
<a name="81" href="#81">81</a>
<a name="82" href="#82">82</a> <b>protected</b> <b>static</b> <b>final</b> String MESSAGE_INVALID_TEST = <font color="#000099">"INVALID TEST: COOKIE NAME NOT SET"</font>;
<a name="83" href="#83">83</a> <b>protected</b> <b>static</b> <b>final</b> String MESSAGE_NONEXISTENT_COOKIE = <font color="#000099">"COOKIE NOT IN SESSION"</font>;
<a name="84" href="#84">84</a> <b>protected</b> <b>static</b> <b>final</b> String MESSAGE_UNEQUAL_VALUES = <font color="#000099">"COOKIE VALUES UNEQUAL:"</font>;
<a name="85" href="#85">85</a>
<a name="86" href="#86">86</a> <font color="#329900"><i>// ------------------------------------------------------------- Constructors</font></i>
<a name="87" href="#87">87</a>
<a name="88" href="#88">88</a> <b>public</b> <a href="../../../../../org/apache/commons/latka/validators/CookieValidator.html">CookieValidator</a>() {
<a name="89" href="#89">89</a> <b>this</b>(<b>null</b>,<b>null</b>,<b>null</b>);
<a name="90" href="#90">90</a> }
<a name="91" href="#91">91</a>
<a name="92" href="#92">92</a> <b>public</b> <a href="../../../../../org/apache/commons/latka/validators/CookieValidator.html">CookieValidator</a>(String label) {
<a name="93" href="#93">93</a> <b>this</b>(label,<b>null</b>,<b>null</b>);
<a name="94" href="#94">94</a> }
<a name="95" href="#95">95</a>
<a name="96" href="#96">96</a> <b>public</b> <a href="../../../../../org/apache/commons/latka/validators/CookieValidator.html">CookieValidator</a>(String name, String value) {
<a name="97" href="#97">97</a> <b>this</b>(<b>null</b>,name,value);
<a name="98" href="#98">98</a> }
<a name="99" href="#99">99</a>
<a name="100" href="#100">100</a> <b>public</b> <a href="../../../../../org/apache/commons/latka/validators/CookieValidator.html">CookieValidator</a>(String label, String name, String value) {
<a name="101" href="#101">101</a> <b>super</b>(label);
<a name="102" href="#102">102</a> _cookieName = name;
<a name="103" href="#103">103</a> _cookieValue = value;
<a name="104" href="#104">104</a> }
<a name="105" href="#105">105</a>
<a name="106" href="#106">106</a> <font color="#329900"><i>// ------------------------------------------------------------------ Methods</font></i>
<a name="107" href="#107">107</a>
<a name="108" href="#108">108</a> <font color="#AA0000"><i>/**<font color="#AA0000"><i>*</font></i></font></i>
<a name="109" href="#109">109</a> <font color="#AA0000"><i> * If cookie value is set, this <code>Validator</code> tests for cookie value equivalency, in addition to cookie existence</font></i>
<a name="110" href="#110">110</a> <font color="#AA0000"><i> *</font></i>
<a name="111" href="#111">111</a> <font color="#AA0000"><i> * @param value the value of the cookie</font></i>
<a name="112" href="#112">112</a> <font color="#AA0000"><i> */</font></i>
<a name="113" href="#113">113</a> <b>public</b> <b>void</b> setCookieValue(String value) {
<a name="114" href="#114">114</a> _cookieValue = value;
<a name="115" href="#115">115</a> }
<a name="116" href="#116">116</a>
<a name="117" href="#117">117</a> <font color="#AA0000"><i>/**<font color="#AA0000"><i>*</font></i></font></i>
<a name="118" href="#118">118</a> <font color="#AA0000"><i> * The cookie name must be set for this <code>Validator</code> to function properly.</font></i>
<a name="119" href="#119">119</a> <font color="#AA0000"><i> *</font></i>
<a name="120" href="#120">120</a> <font color="#AA0000"><i> * @param name the name of the cookie</font></i>
<a name="121" href="#121">121</a> <font color="#AA0000"><i> */</font></i>
<a name="122" href="#122">122</a> <b>public</b> <b>void</b> setCookieName(String name) {
<a name="123" href="#123">123</a> _cookieName = name;
<a name="124" href="#124">124</a> }
<a name="125" href="#125">125</a>
<a name="126" href="#126">126</a> <font color="#AA0000"><i>/**<font color="#AA0000"><i>*</font></i></font></i>
<a name="127" href="#127">127</a> <font color="#AA0000"><i> * @throws org.apache.commons.latka.ValidationException</font></i>
<a name="128" href="#128">128</a> <font color="#AA0000"><i> * if cookie name hasn't been set, the cookie doesn't exist in the session, or if cookie value has been set and the cookie values don't match</font></i>
<a name="129" href="#129">129</a> <font color="#AA0000"><i> */</font></i>
<a name="130" href="#130">130</a> <b>public</b> <b>void</b> validate(<a href="../../../../../org/apache/commons/latka/http/Response.html">Response</a> response)
<a name="131" href="#131">131</a> throws <a href="../../../../../org/apache/commons/latka/ValidationException.html">ValidationException</a> {
<a name="132" href="#132">132</a>
<a name="133" href="#133">133</a> <b>if</b>(_cookieName != <b>null</b>) {
<a name="134" href="#134">134</a> <a href="../../../../../org/apache/commons/latka/http/Session.html">Session</a> session = response.getRequest().getSession();
<a name="135" href="#135">135</a>
<a name="136" href="#136">136</a> String value = session.getCookieValue(_cookieName);
<a name="137" href="#137">137</a>
<a name="138" href="#138">138</a> <font color="#329900"><i>// existence test</font></i>
<a name="139" href="#139">139</a> <b>if</b>(value == <b>null</b>) {
<a name="140" href="#140">140</a> fail(MESSAGE_NONEXISTENT_COOKIE);
<a name="141" href="#141">141</a> }
<a name="142" href="#142">142</a> <font color="#329900"><i>// value test</font></i>
<a name="143" href="#143">143</a> <b>else</b> <b>if</b>(_cookieValue != <b>null</b>) {
<a name="144" href="#144">144</a> <b>if</b>(!_cookieValue.equals(value)) {
<a name="145" href="#145">145</a> StringBuffer buffer = <b>new</b> StringBuffer(MESSAGE_UNEQUAL_VALUES);
<a name="146" href="#146">146</a> buffer.append(<font color="#000099">" EXPECTED: "</font>);
<a name="147" href="#147">147</a> buffer.append(_cookieValue);
<a name="148" href="#148">148</a> buffer.append(<font color="#000099">" RECEIVED: "</font>);
<a name="149" href="#149">149</a> buffer.append(value);
<a name="150" href="#150">150</a> fail(buffer.toString());
<a name="151" href="#151">151</a> }
<a name="152" href="#152">152</a> }
<a name="153" href="#153">153</a> }
<a name="154" href="#154">154</a> <font color="#329900"><i>// invalid test</font></i>
<a name="155" href="#155">155</a> <b>else</b> {
<a name="156" href="#156">156</a> fail(MESSAGE_INVALID_TEST);
<a name="157" href="#157">157</a> }
<a name="158" href="#158">158</a> }
<a name="159" href="#159">159</a>
<a name="160" href="#160">160</a> }
</pre>
<hr><center>This page automatically generated by Maven</center></body>
</html>
1.1 jakarta-commons/docs/latka/xref/java/org/apache/commons/latka/validators/CookieHandler.html
Index: CookieHandler.html
===================================================================
<html>
<body bgcolor="white">
<pre>
<table bgcolor="#FFFFCC" cellpadding="0" cellspacing="0" border="0" width="100%"><a href="../../../../../../../apidocs/org/apache/commons/latka/validators/CookieHandler.html">View Javadoc</a></table>
<a name="1" href="#1">1</a> <font color="#329900"><i>/*</font></i>
<a name="2" href="#2">2</a> <font color="#329900"><i> * ====================================================================</font></i>
<a name="3" href="#3">3</a> <font color="#329900"><i> *</font></i>
<a name="4" href="#4">4</a> <font color="#329900"><i> * The Apache Software License, Version 1.1</font></i>
<a name="5" href="#5">5</a> <font color="#329900"><i> *</font></i>
<a name="6" href="#6">6</a> <font color="#329900"><i> * Copyright (c) 1999 The Apache Software Foundation. All rights </font></i>
<a name="7" href="#7">7</a> <font color="#329900"><i> * reserved.</font></i>
<a name="8" href="#8">8</a> <font color="#329900"><i> *</font></i>
<a name="9" href="#9">9</a> <font color="#329900"><i> * Redistribution and use in source and binary forms, with or without</font></i>
<a name="10" href="#10">10</a> <font color="#329900"><i> * modification, are permitted provided that the following conditions</font></i>
<a name="11" href="#11">11</a> <font color="#329900"><i> * are met:</font></i>
<a name="12" href="#12">12</a> <font color="#329900"><i> *</font></i>
<a name="13" href="#13">13</a> <font color="#329900"><i> * 1. Redistributions of source code must retain the above copyright</font></i>
<a name="14" href="#14">14</a> <font color="#329900"><i> * notice, this list of conditions and the following disclaimer. </font></i>
<a name="15" href="#15">15</a> <font color="#329900"><i> *</font></i>
<a name="16" href="#16">16</a> <font color="#329900"><i> * 2. Redistributions in binary form must reproduce the above copyright</font></i>
<a name="17" href="#17">17</a> <font color="#329900"><i> * notice, this list of conditions and the following disclaimer in</font></i>
<a name="18" href="#18">18</a> <font color="#329900"><i> * the documentation and/or other materials provided with the</font></i>
<a name="19" href="#19">19</a> <font color="#329900"><i> * distribution.</font></i>
<a name="20" href="#20">20</a> <font color="#329900"><i> *</font></i>
<a name="21" href="#21">21</a> <font color="#329900"><i> * 3. The end-user documentation included with the redistribution, if</font></i>
<a name="22" href="#22">22</a> <font color="#329900"><i> * any, must include the following acknowlegement: </font></i>
<a name="23" href="#23">23</a> <font color="#329900"><i> * "This product includes software developed by the </font></i>
<a name="24" href="#24">24</a> <font color="#329900"><i> * Apache Software Foundation (<a href="http://www.apache.org/" target="alexandria_uri">http://www.apache.org/</a>)."</font></i>
<a name="25" href="#25">25</a> <font color="#329900"><i> * Alternately, this acknowlegement may appear in the software itself,</font></i>
<a name="26" href="#26">26</a> <font color="#329900"><i> * if and wherever such third-party acknowlegements normally appear.</font></i>
<a name="27" href="#27">27</a> <font color="#329900"><i> *</font></i>
<a name="28" href="#28">28</a> <font color="#329900"><i> * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software</font></i>
<a name="29" href="#29">29</a> <font color="#329900"><i> * Foundation" must not be used to endorse or promote products derived</font></i>
<a name="30" href="#30">30</a> <font color="#329900"><i> * from this software without prior written permission. For written </font></i>
<a name="31" href="#31">31</a> <font color="#329900"><i> * permission, please contact apache@apache.org.</font></i>
<a name="32" href="#32">32</a> <font color="#329900"><i> *</font></i>
<a name="33" href="#33">33</a> <font color="#329900"><i> * 5. Products derived from this software may not be called "Apache"</font></i>
<a name="34" href="#34">34</a> <font color="#329900"><i> * nor may "Apache" appear in their names without prior written</font></i>
<a name="35" href="#35">35</a> <font color="#329900"><i> * permission of the Apache Group.</font></i>
<a name="36" href="#36">36</a> <font color="#329900"><i> *</font></i>
<a name="37" href="#37">37</a> <font color="#329900"><i> * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED</font></i>
<a name="38" href="#38">38</a> <font color="#329900"><i> * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES</font></i>
<a name="39" href="#39">39</a> <font color="#329900"><i> * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE</font></i>
<a name="40" href="#40">40</a> <font color="#329900"><i> * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR</font></i>
<a name="41" href="#41">41</a> <font color="#329900"><i> * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,</font></i>
<a name="42" href="#42">42</a> <font color="#329900"><i> * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT</font></i>
<a name="43" href="#43">43</a> <font color="#329900"><i> * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF</font></i>
<a name="44" href="#44">44</a> <font color="#329900"><i> * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND</font></i>
<a name="45" href="#45">45</a> <font color="#329900"><i> * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,</font></i>
<a name="46" href="#46">46</a> <font color="#329900"><i> * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT</font></i>
<a name="47" href="#47">47</a> <font color="#329900"><i> * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF</font></i>
<a name="48" href="#48">48</a> <font color="#329900"><i> * SUCH DAMAGE.</font></i>
<a name="49" href="#49">49</a> <font color="#329900"><i> * ====================================================================</font></i>
<a name="50" href="#50">50</a> <font color="#329900"><i> *</font></i>
<a name="51" href="#51">51</a> <font color="#329900"><i> * This software consists of voluntary contributions made by many</font></i>
<a name="52" href="#52">52</a> <font color="#329900"><i> * individuals on behalf of the Apache Software Foundation. For more</font></i>
<a name="53" href="#53">53</a> <font color="#329900"><i> * information on the Apache Software Foundation, please see</font></i>
<a name="54" href="#54">54</a> <font color="#329900"><i> * <<a href="http://www.apache.org/>" target="alexandria_uri">http://www.apache.org/></a>;.</font></i>
<a name="55" href="#55">55</a> <font color="#329900"><i> *</font></i>
<a name="56" href="#56">56</a> <font color="#329900"><i> * [Additional notices, if required by prior licensing conditions]</font></i>
<a name="57" href="#57">57</a> <font color="#329900"><i> *</font></i>
<a name="58" href="#58">58</a> <font color="#329900"><i> */</font></i>
<a name="59" href="#59">59</a>
<a name="60" href="#60">60</a> <b>package</b> <a href="../../../../../org/apache/commons/latka/validators/index.html">org.apache.commons.latka.validators</a>;
<a name="61" href="#61">61</a>
<a name="62" href="#62">62</a> <b>import</b> <a href="../../../../../org/apache/commons/latka/xml/index.html">org.apache.commons.latka.xml</a>.<a href="../../../../../org/apache/commons/latka/xml/ValidationHandler.html">ValidationHandler</a>;
<a name="63" href="#63">63</a>
<a name="64" href="#64">64</a> <b>import</b> org.xml.sax.Attributes;
<a name="65" href="#65">65</a> <b>import</b> org.xml.sax.SAXException;
<a name="66" href="#66">66</a>
<a name="67" href="#67">67</a> <b>public</b> <b>class</b> <a href="../../../../../org/apache/commons/latka/validators/CookieHandler.html">CookieHandler</a> <b>extends</b> <a href="../../../../../org/apache/commons/latka/xml/ValidationHandler.html">ValidationHandler</a> {
<a name="68" href="#68">68</a>
<a name="69" href="#69">69</a> <b>public</b> <b>void</b> startElement(String uri, String localName,
<a name="70" href="#70">70</a> String qName, Attributes atts)
<a name="71" href="#71">71</a> throws SAXException {
<a name="72" href="#72">72</a>
<a name="73" href="#73">73</a> <a href="../../../../../org/apache/commons/latka/validators/CookieValidator.html">CookieValidator</a> validator =
<a name="74" href="#74">74</a> <b>new</b> <a href="../../../../../org/apache/commons/latka/validators/CookieValidator.html">CookieValidator</a>(atts.getValue(<font color="#000099">"label"</font>));
<a name="75" href="#75">75</a>
<a name="76" href="#76">76</a> String cookieName = atts.getValue(<font color="#000099">"name"</font>);
<a name="77" href="#77">77</a> <b>if</b> (cookieName != <b>null</b>) {
<a name="78" href="#78">78</a> validator.setCookieName(cookieName);
<a name="79" href="#79">79</a> }
<a name="80" href="#80">80</a> String cookieValue = atts.getValue(<font color="#000099">"value"</font>);
<a name="81" href="#81">81</a> <b>if</b> (cookieValue != <b>null</b>) {
<a name="82" href="#82">82</a> validator.setCookieValue(cookieValue);
<a name="83" href="#83">83</a> }
<a name="84" href="#84">84</a>
<a name="85" href="#85">85</a> validate(validator);
<a name="86" href="#86">86</a>
<a name="87" href="#87">87</a> }
<a name="88" href="#88">88</a>
<a name="89" href="#89">89</a> }
</pre>
<hr><center>This page automatically generated by Maven</center></body>
</html>
1.1 jakarta-commons/docs/latka/xref/java/org/apache/commons/latka/validators/ByteLengthValidator.html
Index: ByteLengthValidator.html
===================================================================
<html>
<body bgcolor="white">
<pre>
<table bgcolor="#FFFFCC" cellpadding="0" cellspacing="0" border="0" width="100%"><a href="../../../../../../../apidocs/org/apache/commons/latka/validators/ByteLengthValidator.html">View Javadoc</a></table>
<a name="1" href="#1">1</a> <font color="#329900"><i>/*</font></i>
<a name="2" href="#2">2</a> <font color="#329900"><i> * ====================================================================</font></i>
<a name="3" href="#3">3</a> <font color="#329900"><i> *</font></i>
<a name="4" href="#4">4</a> <font color="#329900"><i> * The Apache Software License, Version 1.1</font></i>
<a name="5" href="#5">5</a> <font color="#329900"><i> *</font></i>
<a name="6" href="#6">6</a> <font color="#329900"><i> * Copyright (c) 1999 The Apache Software Foundation. All rights </font></i>
<a name="7" href="#7">7</a> <font color="#329900"><i> * reserved.</font></i>
<a name="8" href="#8">8</a> <font color="#329900"><i> *</font></i>
<a name="9" href="#9">9</a> <font color="#329900"><i> * Redistribution and use in source and binary forms, with or without</font></i>
<a name="10" href="#10">10</a> <font color="#329900"><i> * modification, are permitted provided that the following conditions</font></i>
<a name="11" href="#11">11</a> <font color="#329900"><i> * are met:</font></i>
<a name="12" href="#12">12</a> <font color="#329900"><i> *</font></i>
<a name="13" href="#13">13</a> <font color="#329900"><i> * 1. Redistributions of source code must retain the above copyright</font></i>
<a name="14" href="#14">14</a> <font color="#329900"><i> * notice, this list of conditions and the following disclaimer. </font></i>
<a name="15" href="#15">15</a> <font color="#329900"><i> *</font></i>
<a name="16" href="#16">16</a> <font color="#329900"><i> * 2. Redistributions in binary form must reproduce the above copyright</font></i>
<a name="17" href="#17">17</a> <font color="#329900"><i> * notice, this list of conditions and the following disclaimer in</font></i>
<a name="18" href="#18">18</a> <font color="#329900"><i> * the documentation and/or other materials provided with the</font></i>
<a name="19" href="#19">19</a> <font color="#329900"><i> * distribution.</font></i>
<a name="20" href="#20">20</a> <font color="#329900"><i> *</font></i>
<a name="21" href="#21">21</a> <font color="#329900"><i> * 3. The end-user documentation included with the redistribution, if</font></i>
<a name="22" href="#22">22</a> <font color="#329900"><i> * any, must include the following acknowlegement: </font></i>
<a name="23" href="#23">23</a> <font color="#329900"><i> * "This product includes software developed by the </font></i>
<a name="24" href="#24">24</a> <font color="#329900"><i> * Apache Software Foundation (<a href="http://www.apache.org/" target="alexandria_uri">http://www.apache.org/</a>)."</font></i>
<a name="25" href="#25">25</a> <font color="#329900"><i> * Alternately, this acknowlegement may appear in the software itself,</font></i>
<a name="26" href="#26">26</a> <font color="#329900"><i> * if and wherever such third-party acknowlegements normally appear.</font></i>
<a name="27" href="#27">27</a> <font color="#329900"><i> *</font></i>
<a name="28" href="#28">28</a> <font color="#329900"><i> * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software</font></i>
<a name="29" href="#29">29</a> <font color="#329900"><i> * Foundation" must not be used to endorse or promote products derived</font></i>
<a name="30" href="#30">30</a> <font color="#329900"><i> * from this software without prior written permission. For written </font></i>
<a name="31" href="#31">31</a> <font color="#329900"><i> * permission, please contact apache@apache.org.</font></i>
<a name="32" href="#32">32</a> <font color="#329900"><i> *</font></i>
<a name="33" href="#33">33</a> <font color="#329900"><i> * 5. Products derived from this software may not be called "Apache"</font></i>
<a name="34" href="#34">34</a> <font color="#329900"><i> * nor may "Apache" appear in their names without prior written</font></i>
<a name="35" href="#35">35</a> <font color="#329900"><i> * permission of the Apache Group.</font></i>
<a name="36" href="#36">36</a> <font color="#329900"><i> *</font></i>
<a name="37" href="#37">37</a> <font color="#329900"><i> * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED</font></i>
<a name="38" href="#38">38</a> <font color="#329900"><i> * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES</font></i>
<a name="39" href="#39">39</a> <font color="#329900"><i> * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE</font></i>
<a name="40" href="#40">40</a> <font color="#329900"><i> * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR</font></i>
<a name="41" href="#41">41</a> <font color="#329900"><i> * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,</font></i>
<a name="42" href="#42">42</a> <font color="#329900"><i> * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT</font></i>
<a name="43" href="#43">43</a> <font color="#329900"><i> * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF</font></i>
<a name="44" href="#44">44</a> <font color="#329900"><i> * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND</font></i>
<a name="45" href="#45">45</a> <font color="#329900"><i> * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,</font></i>
<a name="46" href="#46">46</a> <font color="#329900"><i> * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT</font></i>
<a name="47" href="#47">47</a> <font color="#329900"><i> * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF</font></i>
<a name="48" href="#48">48</a> <font color="#329900"><i> * SUCH DAMAGE.</font></i>
<a name="49" href="#49">49</a> <font color="#329900"><i> * ====================================================================</font></i>
<a name="50" href="#50">50</a> <font color="#329900"><i> *</font></i>
<a name="51" href="#51">51</a> <font color="#329900"><i> * This software consists of voluntary contributions made by many</font></i>
<a name="52" href="#52">52</a> <font color="#329900"><i> * individuals on behalf of the Apache Software Foundation. For more</font></i>
<a name="53" href="#53">53</a> <font color="#329900"><i> * information on the Apache Software Foundation, please see</font></i>
<a name="54" href="#54">54</a> <font color="#329900"><i> * <<a href="http://www.apache.org/>" target="alexandria_uri">http://www.apache.org/></a>;.</font></i>
<a name="55" href="#55">55</a> <font color="#329900"><i> *</font></i>
<a name="56" href="#56">56</a> <font color="#329900"><i> * [Additional notices, if required by prior licensing conditions]</font></i>
<a name="57" href="#57">57</a> <font color="#329900"><i> *</font></i>
<a name="58" href="#58">58</a> <font color="#329900"><i> */</font></i>
<a name="59" href="#59">59</a>
<a name="60" href="#60">60</a> <b>package</b> <a href="../../../../../org/apache/commons/latka/validators/index.html">org.apache.commons.latka.validators</a>;
<a name="61" href="#61">61</a>
<a name="62" href="#62">62</a> <b>import</b> <a href="../../../../../org/apache/commons/latka/index.html">org.apache.commons.latka</a>.<a href="../../../../../org/apache/commons/latka/Validator.html">Validator</a>;
<a name="63" href="#63">63</a> <b>import</b> <a href="../../../../../org/apache/commons/latka/index.html">org.apache.commons.latka</a>.<a href="../../../../../org/apache/commons/latka/ValidationException.html">ValidationException</a>;
<a name="64" href="#64">64</a>
<a name="65" href="#65">65</a> <b>import</b> <a href="../../../../../org/apache/commons/latka/http/index.html">org.apache.commons.latka.http</a>.<a href="../../../../../org/apache/commons/latka/http/Response.html">Response</a>;
<a name="66" href="#66">66</a>
<a name="67" href="#67">67</a> <b>import</b> java.text.MessageFormat;
<a name="68" href="#68">68</a> <font color="#AA0000"><i>/**<font color="#AA0000"><i>*</font></i></font></i>
<a name="69" href="#69">69</a> <font color="#AA0000"><i> * FIXME: Docs</font></i>
<a name="70" href="#70">70</a> <font color="#AA0000"><i> *</font></i>
<a name="71" href="#71">71</a> <font color="#AA0000"><i> * @author Morgan Delagrange</font></i>
<a name="72" href="#72">72</a> <font color="#AA0000"><i> * @author dIon Gillard</font></i>
<a name="73" href="#73">73</a> <font color="#AA0000"><i> * @version $Id: ByteLengthValidator.html,v 1.1 2002/04/01 05:44:07 dion Exp $</font></i>
<a name="74" href="#74">74</a> <font color="#AA0000"><i> */</font></i>
<a name="75" href="#75">75</a> <b>public</b> <b>class</b> <a href="../../../../../org/apache/commons/latka/validators/ByteLengthValidator.html">ByteLengthValidator</a> <b>extends</b> <a href="../../../../../org/apache/commons/latka/validators/BaseValidator.html">BaseValidator</a> implements <a href="../../../../../org/apache/commons/latka/Validator.html">Validator</a> {
<a name="76" href="#76">76</a>
<a name="77" href="#77">77</a> <font color="#329900"><i>// --------------------------------------------------------------- Attributes</font></i>
<a name="78" href="#78">78</a>
<a name="79" href="#79">79</a> <b>protected</b> <b>int</b> _minLength = 0;
<a name="80" href="#80">80</a> <b>protected</b> <b>int</b> _maxLength = -1;
<a name="81" href="#81">81</a>
<a name="82" href="#82">82</a> <b>protected</b> <b>static</b> <b>final</b> MessageFormat MAX_MESSAGE = <b>new</b> MessageFormat(<font color="#000099">"Expected at most {0,number,integer} bytes. Found {1,number,integer}."</font>);
<a name="83" href="#83">83</a> <b>protected</b> <b>static</b> <b>final</b> MessageFormat MIN_MESSAGE = <b>new</b> MessageFormat(<font color="#000099">"Expected at least {0,number,integer} bytes. Found {1,number,integer}."</font>);
<a name="84" href="#84">84</a>
<a name="85" href="#85">85</a> <font color="#329900"><i>// ------------------------------------------------------------- Constructors</font></i>
<a name="86" href="#86">86</a>
<a name="87" href="#87">87</a> <b>public</b> <a href="../../../../../org/apache/commons/latka/validators/ByteLengthValidator.html">ByteLengthValidator</a>() {
<a name="88" href="#88">88</a> <b>this</b>(<b>null</b>,0,-1);
<a name="89" href="#89">89</a> }
<a name="90" href="#90">90</a>
<a name="91" href="#91">91</a> <b>public</b> <a href="../../../../../org/apache/commons/latka/validators/ByteLengthValidator.html">ByteLengthValidator</a>(String label) {
<a name="92" href="#92">92</a> <b>this</b>(label,0,-1);
<a name="93" href="#93">93</a> }
<a name="94" href="#94">94</a>
<a name="95" href="#95">95</a> <b>public</b> <a href="../../../../../org/apache/commons/latka/validators/ByteLengthValidator.html">ByteLengthValidator</a>(<b>int</b> min, <b>int</b> max) {
<a name="96" href="#96">96</a> <b>this</b>(<b>null</b>,min,max);
<a name="97" href="#97">97</a> }
<a name="98" href="#98">98</a>
<a name="99" href="#99">99</a> <b>public</b> <a href="../../../../../org/apache/commons/latka/validators/ByteLengthValidator.html">ByteLengthValidator</a>(String label, <b>int</b> min, <b>int</b> max) {
<a name="100" href="#100">100</a> <b>super</b>(label);
<a name="101" href="#101">101</a> _minLength = min;
<a name="102" href="#102">102</a> _maxLength = max;
<a name="103" href="#103">103</a> }
<a name="104" href="#104">104</a>
<a name="105" href="#105">105</a> <font color="#329900"><i>// ------------------------------------------------------------------ Methods</font></i>
<a name="106" href="#106">106</a>
<a name="107" href="#107">107</a> <b>public</b> <b>void</b> setMinLength(<b>int</b> length) {
<a name="108" href="#108">108</a> _minLength = length;
<a name="109" href="#109">109</a> }
<a name="110" href="#110">110</a>
<a name="111" href="#111">111</a> <b>public</b> <b>void</b> setMaxLength(<b>int</b> length) {
<a name="112" href="#112">112</a> _maxLength = length;
<a name="113" href="#113">113</a> }
<a name="114" href="#114">114</a>
<a name="115" href="#115">115</a> <b>public</b> <b>void</b> validate(<a href="../../../../../org/apache/commons/latka/http/Response.html">Response</a> response)
<a name="116" href="#116">116</a> throws <a href="../../../../../org/apache/commons/latka/ValidationException.html">ValidationException</a> {
<a name="117" href="#117">117</a>
<a name="118" href="#118">118</a> <b>int</b> byteLength = response.getByteLength();
<a name="119" href="#119">119</a>
<a name="120" href="#120">120</a> <b>if</b> (_maxLength > -1) {
<a name="121" href="#121">121</a> <b>if</b> (byteLength > _maxLength) {
<a name="122" href="#122">122</a> fail(MAX_MESSAGE.format(<b>new</b> Object[] { <b>new</b> Integer(_maxLength), <b>new</b> Integer(byteLength) }).toString());
<a name="123" href="#123">123</a> }
<a name="124" href="#124">124</a> }
<a name="125" href="#125">125</a>
<a name="126" href="#126">126</a> <b>if</b> (byteLength < _minLength) {
<a name="127" href="#127">127</a> fail(MIN_MESSAGE.format(<b>new</b> Object[] { <b>new</b> Integer(_minLength), <b>new</b> Integer(byteLength) }).toString());
<a name="128" href="#128">128</a> }
<a name="129" href="#129">129</a> }
<a name="130" href="#130">130</a>
<a name="131" href="#131">131</a> }
</pre>
<hr><center>This page automatically generated by Maven</center></body>
</html>
1.1 jakarta-commons/docs/latka/xref/java/org/apache/commons/latka/validators/ByteLengthHandler.html
Index: ByteLengthHandler.html
===================================================================
<html>
<body bgcolor="white">
<pre>
<table bgcolor="#FFFFCC" cellpadding="0" cellspacing="0" border="0" width="100%"><a href="../../../../../../../apidocs/org/apache/commons/latka/validators/ByteLengthHandler.html">View Javadoc</a></table>
<a name="1" href="#1">1</a>
<a name="2" href="#2">2</a> <font color="#329900"><i>/*</font></i>
<a name="3" href="#3">3</a> <font color="#329900"><i> * ====================================================================</font></i>
<a name="4" href="#4">4</a> <font color="#329900"><i> *</font></i>
<a name="5" href="#5">5</a> <font color="#329900"><i> * The Apache Software License, Version 1.1</font></i>
<a name="6" href="#6">6</a> <font color="#329900"><i> *</font></i>
<a name="7" href="#7">7</a> <font color="#329900"><i> * Copyright (c) 1999 The Apache Software Foundation. All rights </font></i>
<a name="8" href="#8">8</a> <font color="#329900"><i> * reserved.</font></i>
<a name="9" href="#9">9</a> <font color="#329900"><i> *</font></i>
<a name="10" href="#10">10</a> <font color="#329900"><i> * Redistribution and use in source and binary forms, with or without</font></i>
<a name="11" href="#11">11</a> <font color="#329900"><i> * modification, are permitted provided that the following conditions</font></i>
<a name="12" href="#12">12</a> <font color="#329900"><i> * are met:</font></i>
<a name="13" href="#13">13</a> <font color="#329900"><i> *</font></i>
<a name="14" href="#14">14</a> <font color="#329900"><i> * 1. Redistributions of source code must retain the above copyright</font></i>
<a name="15" href="#15">15</a> <font color="#329900"><i> * notice, this list of conditions and the following disclaimer. </font></i>
<a name="16" href="#16">16</a> <font color="#329900"><i> *</font></i>
<a name="17" href="#17">17</a> <font color="#329900"><i> * 2. Redistributions in binary form must reproduce the above copyright</font></i>
<a name="18" href="#18">18</a> <font color="#329900"><i> * notice, this list of conditions and the following disclaimer in</font></i>
<a name="19" href="#19">19</a> <font color="#329900"><i> * the documentation and/or other materials provided with the</font></i>
<a name="20" href="#20">20</a> <font color="#329900"><i> * distribution.</font></i>
<a name="21" href="#21">21</a> <font color="#329900"><i> *</font></i>
<a name="22" href="#22">22</a> <font color="#329900"><i> * 3. The end-user documentation included with the redistribution, if</font></i>
<a name="23" href="#23">23</a> <font color="#329900"><i> * any, must include the following acknowlegement: </font></i>
<a name="24" href="#24">24</a> <font color="#329900"><i> * "This product includes software developed by the </font></i>
<a name="25" href="#25">25</a> <font color="#329900"><i> * Apache Software Foundation (<a href="http://www.apache.org/" target="alexandria_uri">http://www.apache.org/</a>)."</font></i>
<a name="26" href="#26">26</a> <font color="#329900"><i> * Alternately, this acknowlegement may appear in the software itself,</font></i>
<a name="27" href="#27">27</a> <font color="#329900"><i> * if and wherever such third-party acknowlegements normally appear.</font></i>
<a name="28" href="#28">28</a> <font color="#329900"><i> *</font></i>
<a name="29" href="#29">29</a> <font color="#329900"><i> * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software</font></i>
<a name="30" href="#30">30</a> <font color="#329900"><i> * Foundation" must not be used to endorse or promote products derived</font></i>
<a name="31" href="#31">31</a> <font color="#329900"><i> * from this software without prior written permission. For written </font></i>
<a name="32" href="#32">32</a> <font color="#329900"><i> * permission, please contact apache@apache.org.</font></i>
<a name="33" href="#33">33</a> <font color="#329900"><i> *</font></i>
<a name="34" href="#34">34</a> <font color="#329900"><i> * 5. Products derived from this software may not be called "Apache"</font></i>
<a name="35" href="#35">35</a> <font color="#329900"><i> * nor may "Apache" appear in their names without prior written</font></i>
<a name="36" href="#36">36</a> <font color="#329900"><i> * permission of the Apache Group.</font></i>
<a name="37" href="#37">37</a> <font color="#329900"><i> *</font></i>
<a name="38" href="#38">38</a> <font color="#329900"><i> * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED</font></i>
<a name="39" href="#39">39</a> <font color="#329900"><i> * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES</font></i>
<a name="40" href="#40">40</a> <font color="#329900"><i> * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE</font></i>
<a name="41" href="#41">41</a> <font color="#329900"><i> * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR</font></i>
<a name="42" href="#42">42</a> <font color="#329900"><i> * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,</font></i>
<a name="43" href="#43">43</a> <font color="#329900"><i> * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT</font></i>
<a name="44" href="#44">44</a> <font color="#329900"><i> * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF</font></i>
<a name="45" href="#45">45</a> <font color="#329900"><i> * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND</font></i>
<a name="46" href="#46">46</a> <font color="#329900"><i> * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,</font></i>
<a name="47" href="#47">47</a> <font color="#329900"><i> * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT</font></i>
<a name="48" href="#48">48</a> <font color="#329900"><i> * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF</font></i>
<a name="49" href="#49">49</a> <font color="#329900"><i> * SUCH DAMAGE.</font></i>
<a name="50" href="#50">50</a> <font color="#329900"><i> * ====================================================================</font></i>
<a name="51" href="#51">51</a> <font color="#329900"><i> *</font></i>
<a name="52" href="#52">52</a> <font color="#329900"><i> * This software consists of voluntary contributions made by many</font></i>
<a name="53" href="#53">53</a> <font color="#329900"><i> * individuals on behalf of the Apache Software Foundation. For more</font></i>
<a name="54" href="#54">54</a> <font color="#329900"><i> * information on the Apache Software Foundation, please see</font></i>
<a name="55" href="#55">55</a> <font color="#329900"><i> * <<a href="http://www.apache.org/>" target="alexandria_uri">http://www.apache.org/></a>;.</font></i>
<a name="56" href="#56">56</a> <font color="#329900"><i> *</font></i>
<a name="57" href="#57">57</a> <font color="#329900"><i> * [Additional notices, if required by prior licensing conditions]</font></i>
<a name="58" href="#58">58</a> <font color="#329900"><i> *</font></i>
<a name="59" href="#59">59</a> <font color="#329900"><i> */</font></i>
<a name="60" href="#60">60</a> <b>package</b> <a href="../../../../../org/apache/commons/latka/validators/index.html">org.apache.commons.latka.validators</a>;
<a name="61" href="#61">61</a>
<a name="62" href="#62">62</a> <b>import</b> <a href="../../../../../org/apache/commons/latka/xml/index.html">org.apache.commons.latka.xml</a>.<a href="../../../../../org/apache/commons/latka/xml/ValidationHandler.html">ValidationHandler</a>;
<a name="63" href="#63">63</a>
<a name="64" href="#64">64</a> <b>import</b> org.xml.sax.Attributes;
<a name="65" href="#65">65</a> <b>import</b> org.xml.sax.SAXException;
<a name="66" href="#66">66</a>
<a name="67" href="#67">67</a> <b>public</b> <b>class</b> <a href="../../../../../org/apache/commons/latka/validators/ByteLengthHandler.html">ByteLengthHandler</a> <b>extends</b> <a href="../../../../../org/apache/commons/latka/xml/ValidationHandler.html">ValidationHandler</a> {
<a name="68" href="#68">68</a>
<a name="69" href="#69">69</a> <b>public</b> <b>void</b> startElement(String uri, String localName,
<a name="70" href="#70">70</a> String qName, Attributes atts)
<a name="71" href="#71">71</a> throws SAXException {
<a name="72" href="#72">72</a>
<a name="73" href="#73">73</a> <a href="../../../../../org/apache/commons/latka/validators/ByteLengthValidator.html">ByteLengthValidator</a> validator =
<a name="74" href="#74">74</a> <b>new</b> <a href="../../../../../org/apache/commons/latka/validators/ByteLengthValidator.html">ByteLengthValidator</a>(atts.getValue(<font color="#000099">"label"</font>));
<a name="75" href="#75">75</a>
<a name="76" href="#76">76</a> String minLength = atts.getValue(<font color="#000099">"min"</font>);
<a name="77" href="#77">77</a> <b>if</b> (minLength != <b>null</b>) {
<a name="78" href="#78">78</a> validator.setMinLength(Integer.parseInt(minLength));
<a name="79" href="#79">79</a> }
<a name="80" href="#80">80</a>
<a name="81" href="#81">81</a> String maxLength = atts.getValue(<font color="#000099">"max"</font>);
<a name="82" href="#82">82</a> <b>if</b> (maxLength != <b>null</b>) {
<a name="83" href="#83">83</a> validator.setMaxLength(Integer.parseInt(maxLength));
<a name="84" href="#84">84</a> }
<a name="85" href="#85">85</a>
<a name="86" href="#86">86</a> validate(validator);
<a name="87" href="#87">87</a>
<a name="88" href="#88">88</a> }
<a name="89" href="#89">89</a>
<a name="90" href="#90">90</a> }
</pre>
<hr><center>This page automatically generated by Maven</center></body>
</html>
1.1 jakarta-commons/docs/latka/xref/java/org/apache/commons/latka/validators/BaseValidator.html
Index: BaseValidator.html
===================================================================
<html>
<body bgcolor="white">
<pre>
<table bgcolor="#FFFFCC" cellpadding="0" cellspacing="0" border="0" width="100%"><a href="../../../../../../../apidocs/org/apache/commons/latka/validators/BaseValidator.html">View Javadoc</a></table>
<a name="1" href="#1">1</a> <font color="#329900"><i>/*</font></i>
<a name="2" href="#2">2</a> <font color="#329900"><i> * ====================================================================</font></i>
<a name="3" href="#3">3</a> <font color="#329900"><i> *</font></i>
<a name="4" href="#4">4</a> <font color="#329900"><i> * The Apache Software License, Version 1.1</font></i>
<a name="5" href="#5">5</a> <font color="#329900"><i> *</font></i>
<a name="6" href="#6">6</a> <font color="#329900"><i> * Copyright (c) 1999 The Apache Software Foundation. All rights </font></i>
<a name="7" href="#7">7</a> <font color="#329900"><i> * reserved.</font></i>
<a name="8" href="#8">8</a> <font color="#329900"><i> *</font></i>
<a name="9" href="#9">9</a> <font color="#329900"><i> * Redistribution and use in source and binary forms, with or without</font></i>
<a name="10" href="#10">10</a> <font color="#329900"><i> * modification, are permitted provided that the following conditions</font></i>
<a name="11" href="#11">11</a> <font color="#329900"><i> * are met:</font></i>
<a name="12" href="#12">12</a> <font color="#329900"><i> *</font></i>
<a name="13" href="#13">13</a> <font color="#329900"><i> * 1. Redistributions of source code must retain the above copyright</font></i>
<a name="14" href="#14">14</a> <font color="#329900"><i> * notice, this list of conditions and the following disclaimer. </font></i>
<a name="15" href="#15">15</a> <font color="#329900"><i> *</font></i>
<a name="16" href="#16">16</a> <font color="#329900"><i> * 2. Redistributions in binary form must reproduce the above copyright</font></i>
<a name="17" href="#17">17</a> <font color="#329900"><i> * notice, this list of conditions and the following disclaimer in</font></i>
<a name="18" href="#18">18</a> <font color="#329900"><i> * the documentation and/or other materials provided with the</font></i>
<a name="19" href="#19">19</a> <font color="#329900"><i> * distribution.</font></i>
<a name="20" href="#20">20</a> <font color="#329900"><i> *</font></i>
<a name="21" href="#21">21</a> <font color="#329900"><i> * 3. The end-user documentation included with the redistribution, if</font></i>
<a name="22" href="#22">22</a> <font color="#329900"><i> * any, must include the following acknowlegement: </font></i>
<a name="23" href="#23">23</a> <font color="#329900"><i> * "This product includes software developed by the </font></i>
<a name="24" href="#24">24</a> <font color="#329900"><i> * Apache Software Foundation (<a href="http://www.apache.org/" target="alexandria_uri">http://www.apache.org/</a>)."</font></i>
<a name="25" href="#25">25</a> <font color="#329900"><i> * Alternately, this acknowlegement may appear in the software itself,</font></i>
<a name="26" href="#26">26</a> <font color="#329900"><i> * if and wherever such third-party acknowlegements normally appear.</font></i>
<a name="27" href="#27">27</a> <font color="#329900"><i> *</font></i>
<a name="28" href="#28">28</a> <font color="#329900"><i> * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software</font></i>
<a name="29" href="#29">29</a> <font color="#329900"><i> * Foundation" must not be used to endorse or promote products derived</font></i>
<a name="30" href="#30">30</a> <font color="#329900"><i> * from this software without prior written permission. For written </font></i>
<a name="31" href="#31">31</a> <font color="#329900"><i> * permission, please contact apache@apache.org.</font></i>
<a name="32" href="#32">32</a> <font color="#329900"><i> *</font></i>
<a name="33" href="#33">33</a> <font color="#329900"><i> * 5. Products derived from this software may not be called "Apache"</font></i>
<a name="34" href="#34">34</a> <font color="#329900"><i> * nor may "Apache" appear in their names without prior written</font></i>
<a name="35" href="#35">35</a> <font color="#329900"><i> * permission of the Apache Group.</font></i>
<a name="36" href="#36">36</a> <font color="#329900"><i> *</font></i>
<a name="37" href="#37">37</a> <font color="#329900"><i> * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED</font></i>
<a name="38" href="#38">38</a> <font color="#329900"><i> * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES</font></i>
<a name="39" href="#39">39</a> <font color="#329900"><i> * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE</font></i>
<a name="40" href="#40">40</a> <font color="#329900"><i> * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR</font></i>
<a name="41" href="#41">41</a> <font color="#329900"><i> * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,</font></i>
<a name="42" href="#42">42</a> <font color="#329900"><i> * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT</font></i>
<a name="43" href="#43">43</a> <font color="#329900"><i> * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF</font></i>
<a name="44" href="#44">44</a> <font color="#329900"><i> * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND</font></i>
<a name="45" href="#45">45</a> <font color="#329900"><i> * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,</font></i>
<a name="46" href="#46">46</a> <font color="#329900"><i> * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT</font></i>
<a name="47" href="#47">47</a> <font color="#329900"><i> * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF</font></i>
<a name="48" href="#48">48</a> <font color="#329900"><i> * SUCH DAMAGE.</font></i>
<a name="49" href="#49">49</a> <font color="#329900"><i> * ====================================================================</font></i>
<a name="50" href="#50">50</a> <font color="#329900"><i> *</font></i>
<a name="51" href="#51">51</a> <font color="#329900"><i> * This software consists of voluntary contributions made by many</font></i>
<a name="52" href="#52">52</a> <font color="#329900"><i> * individuals on behalf of the Apache Software Foundation. For more</font></i>
<a name="53" href="#53">53</a> <font color="#329900"><i> * information on the Apache Software Foundation, please see</font></i>
<a name="54" href="#54">54</a> <font color="#329900"><i> * <<a href="http://www.apache.org/>" target="alexandria_uri">http://www.apache.org/></a>;.</font></i>
<a name="55" href="#55">55</a> <font color="#329900"><i> *</font></i>
<a name="56" href="#56">56</a> <font color="#329900"><i> * [Additional notices, if required by prior licensing conditions]</font></i>
<a name="57" href="#57">57</a> <font color="#329900"><i> *</font></i>
<a name="58" href="#58">58</a> <font color="#329900"><i> */</font></i>
<a name="59" href="#59">59</a>
<a name="60" href="#60">60</a> <b>package</b> <a href="../../../../../org/apache/commons/latka/validators/index.html">org.apache.commons.latka.validators</a>;
<a name="61" href="#61">61</a>
<a name="62" href="#62">62</a> <b>import</b> <a href="../../../../../org/apache/commons/latka/index.html">org.apache.commons.latka</a>.<a href="../../../../../org/apache/commons/latka/Validator.html">Validator</a>;
<a name="63" href="#63">63</a> <b>import</b> <a href="../../../../../org/apache/commons/latka/index.html">org.apache.commons.latka</a>.<a href="../../../../../org/apache/commons/latka/ValidationException.html">ValidationException</a>;
<a name="64" href="#64">64</a>
<a name="65" href="#65">65</a> <b>import</b> <a href="../../../../../org/apache/commons/latka/http/index.html">org.apache.commons.latka.http</a>.<a href="../../../../../org/apache/commons/latka/http/Response.html">Response</a>;
<a name="66" href="#66">66</a>
<a name="67" href="#67">67</a> <b>import</b> org.apache.log4j.Category;
<a name="68" href="#68">68</a>
<a name="69" href="#69">69</a> <font color="#AA0000"><i>/**<font color="#AA0000"><i>*</font></i></font></i>
<a name="70" href="#70">70</a> <font color="#AA0000"><i> * @author Rodney Waldhoff</font></i>
<a name="71" href="#71">71</a> <font color="#AA0000"><i> * @author dIon Gillard</font></i>
<a name="72" href="#72">72</a> <font color="#AA0000"><i> * @version $Id: BaseValidator.html,v 1.1 2002/04/01 05:44:07 dion Exp $</font></i>
<a name="73" href="#73">73</a> <font color="#AA0000"><i> */</font></i>
<a name="74" href="#74">74</a> <b>public</b> <b>abstract</b> <b>class</b> <a href="../../../../../org/apache/commons/latka/validators/BaseValidator.html">BaseValidator</a> implements <a href="../../../../../org/apache/commons/latka/Validator.html">Validator</a> {
<a name="75" href="#75">75</a> <font color="#329900"><i>// ------------------------------------------------------- Instance Variables </font></i>
<a name="76" href="#76">76</a>
<a name="77" href="#77">77</a> <b>protected</b> <b>final</b> Category _log = Category.getInstance(BaseValidator.<b>class</b>);
<a name="78" href="#78">78</a>
<a name="79" href="#79">79</a> <font color="#329900"><i>// ------------------------------------------------------- Abstract Methods</font></i>
<a name="80" href="#80">80</a>
<a name="81" href="#81">81</a> <b>public</b> <b>abstract</b> <b>void</b> validate(<a href="../../../../../org/apache/commons/latka/http/Response.html">Response</a> response) throws ValidationException;
<a name="82" href="#82">82</a>
<a name="83" href="#83">83</a> <b>protected</b> String _label = <b>null</b>;
<a name="84" href="#84">84</a>
<a name="85" href="#85">85</a> <font color="#329900"><i>// ----------------------------------------------------------- Constructors</font></i>
<a name="86" href="#86">86</a>
<a name="87" href="#87">87</a> <b>public</b> <a href="../../../../../org/apache/commons/latka/validators/BaseValidator.html">BaseValidator</a>() {
<a name="88" href="#88">88</a> <b>this</b>(<b>null</b>);
<a name="89" href="#89">89</a> }
<a name="90" href="#90">90</a>
<a name="91" href="#91">91</a> <b>public</b> <a href="../../../../../org/apache/commons/latka/validators/BaseValidator.html">BaseValidator</a>(String label) {
<a name="92" href="#92">92</a> _label = label;
<a name="93" href="#93">93</a> }
<a name="94" href="#94">94</a>
<a name="95" href="#95">95</a> <font color="#329900"><i>// ---------------------------------------------------------------- Methods</font></i>
<a name="96" href="#96">96</a>
<a name="97" href="#97">97</a> <b>public</b> <b>void</b> setLabel(String label) {
<a name="98" href="#98">98</a> _label = label;
<a name="99" href="#99">99</a> }
<a name="100" href="#100">100</a>
<a name="101" href="#101">101</a> <b>public</b> String getLabel() {
<a name="102" href="#102">102</a> <b>return</b> _label;
<a name="103" href="#103">103</a> }
<a name="104" href="#104">104</a>
<a name="105" href="#105">105</a> <b>protected</b> <b>void</b> fail() throws ValidationException {
<a name="106" href="#106">106</a> fail(<b>null</b>);
<a name="107" href="#107">107</a> }
<a name="108" href="#108">108</a>
<a name="109" href="#109">109</a> <b>protected</b> <b>void</b> fail(String reason) throws ValidationException {
<a name="110" href="#110">110</a> <b>throw</b> <b>new</b> <a href="../../../../../org/apache/commons/latka/ValidationException.html">ValidationException</a>(getLabel(),reason);
<a name="111" href="#111">111</a> }
<a name="112" href="#112">112</a>
<a name="113" href="#113">113</a> }
</pre>
<hr><center>This page automatically generated by Maven</center></body>
</html>
--
To unsubscribe, e-mail: <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>
|