You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tika.apache.org by ma...@apache.org on 2007/11/18 23:21:13 UTC

svn commit: r596146 [36/36] - in /incubator/tika/site: ./ apidocs/ apidocs/org/ apidocs/org/apache/ apidocs/org/apache/tika/ apidocs/org/apache/tika/config/ apidocs/org/apache/tika/config/class-use/ apidocs/org/apache/tika/exception/ apidocs/org/apache...

Added: incubator/tika/site/xref/org/apache/tika/utils/RereadableInputStream.html
URL: http://svn.apache.org/viewvc/incubator/tika/site/xref/org/apache/tika/utils/RereadableInputStream.html?rev=596146&view=auto
==============================================================================
--- incubator/tika/site/xref/org/apache/tika/utils/RereadableInputStream.html (added)
+++ incubator/tika/site/xref/org/apache/tika/utils/RereadableInputStream.html Sun Nov 18 14:20:54 2007
@@ -0,0 +1,277 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
+<title>RereadableInputStream xref</title>
+<link type="text/css" rel="stylesheet" href="../../../../stylesheet.css" />
+</head>
+<body>
+<div id="overview"><a href="../../../../../apidocs/org/apache/tika/utils/RereadableInputStream.html">View Javadoc</a></div><pre>
+
+<a name="1" href="#1">1</a>   <em class="jxr_javadoccomment">/**</em>
+<a name="2" href="#2">2</a>   <em class="jxr_javadoccomment"> * Licensed to the Apache Software Foundation (ASF) under one or more</em>
+<a name="3" href="#3">3</a>   <em class="jxr_javadoccomment"> * contributor license agreements.  See the NOTICE file distributed with</em>
+<a name="4" href="#4">4</a>   <em class="jxr_javadoccomment"> * this work for additional information regarding copyright ownership.</em>
+<a name="5" href="#5">5</a>   <em class="jxr_javadoccomment"> * The ASF licenses this file to You under the Apache License, Version 2.0</em>
+<a name="6" href="#6">6</a>   <em class="jxr_javadoccomment"> * (the "License"); you may not use this file except in compliance with</em>
+<a name="7" href="#7">7</a>   <em class="jxr_javadoccomment"> * the License.  You may obtain a copy of the License at</em>
+<a name="8" href="#8">8</a>   <em class="jxr_javadoccomment"> *</em>
+<a name="9" href="#9">9</a>   <em class="jxr_javadoccomment"> *     <a href="http://www.apache.org/licenses/LICENSE-2.0" target="alexandria_uri">http://www.apache.org/licenses/LICENSE-2.0</a></em>
+<a name="10" href="#10">10</a>  <em class="jxr_javadoccomment"> *</em>
+<a name="11" href="#11">11</a>  <em class="jxr_javadoccomment"> * Unless required by applicable law or agreed to in writing, software</em>
+<a name="12" href="#12">12</a>  <em class="jxr_javadoccomment"> * distributed under the License is distributed on an "AS IS" BASIS,</em>
+<a name="13" href="#13">13</a>  <em class="jxr_javadoccomment"> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</em>
+<a name="14" href="#14">14</a>  <em class="jxr_javadoccomment"> * See the License for the specific language governing permissions and</em>
+<a name="15" href="#15">15</a>  <em class="jxr_javadoccomment"> * limitations under the License.</em>
+<a name="16" href="#16">16</a>  <em class="jxr_javadoccomment"> */</em>
+<a name="17" href="#17">17</a>  <strong class="jxr_keyword">package</strong> org.apache.tika.utils;
+<a name="18" href="#18">18</a>  
+<a name="19" href="#19">19</a>  <strong class="jxr_keyword">import</strong> java.io.BufferedInputStream;
+<a name="20" href="#20">20</a>  <strong class="jxr_keyword">import</strong> java.io.BufferedOutputStream;
+<a name="21" href="#21">21</a>  <strong class="jxr_keyword">import</strong> java.io.ByteArrayInputStream;
+<a name="22" href="#22">22</a>  <strong class="jxr_keyword">import</strong> java.io.File;
+<a name="23" href="#23">23</a>  <strong class="jxr_keyword">import</strong> java.io.FileInputStream;
+<a name="24" href="#24">24</a>  <strong class="jxr_keyword">import</strong> java.io.FileOutputStream;
+<a name="25" href="#25">25</a>  <strong class="jxr_keyword">import</strong> java.io.IOException;
+<a name="26" href="#26">26</a>  <strong class="jxr_keyword">import</strong> java.io.InputStream;
+<a name="27" href="#27">27</a>  <strong class="jxr_keyword">import</strong> java.io.OutputStream;
+<a name="28" href="#28">28</a>  
+<a name="29" href="#29">29</a>  
+<a name="30" href="#30">30</a>  <em class="jxr_javadoccomment">/**</em>
+<a name="31" href="#31">31</a>  <em class="jxr_javadoccomment"> * Wraps an input stream, reading it only once, but making it available</em>
+<a name="32" href="#32">32</a>  <em class="jxr_javadoccomment"> * for rereading an arbitrary number of times.  The stream's bytes are</em>
+<a name="33" href="#33">33</a>  <em class="jxr_javadoccomment"> * stored in memory up to a user specified maximum, and then stored in a</em>
+<a name="34" href="#34">34</a>  <em class="jxr_javadoccomment"> * temporary file which is deleted when this class' close() method is called.</em>
+<a name="35" href="#35">35</a>  <em class="jxr_javadoccomment"> */</em>
+<a name="36" href="#36">36</a>  <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../org/apache/tika/utils/RereadableInputStream.html">RereadableInputStream</a> <strong class="jxr_keyword">extends</strong> InputStream {
+<a name="37" href="#37">37</a>  
+<a name="38" href="#38">38</a>  
+<a name="39" href="#39">39</a>      <em class="jxr_javadoccomment">/**</em>
+<a name="40" href="#40">40</a>  <em class="jxr_javadoccomment">     * Input stream originally passed to the constructor.</em>
+<a name="41" href="#41">41</a>  <em class="jxr_javadoccomment">     */</em>
+<a name="42" href="#42">42</a>      <strong class="jxr_keyword">private</strong> InputStream originalInputStream;
+<a name="43" href="#43">43</a>  
+<a name="44" href="#44">44</a>      <em class="jxr_javadoccomment">/**</em>
+<a name="45" href="#45">45</a>  <em class="jxr_javadoccomment">     * The inputStream currently being used by this object to read contents;</em>
+<a name="46" href="#46">46</a>  <em class="jxr_javadoccomment">     * may be the original stream passed in, or a stream that reads</em>
+<a name="47" href="#47">47</a>  <em class="jxr_javadoccomment">     * the saved copy.</em>
+<a name="48" href="#48">48</a>  <em class="jxr_javadoccomment">     */</em>
+<a name="49" href="#49">49</a>      <strong class="jxr_keyword">private</strong> InputStream inputStream;
+<a name="50" href="#50">50</a>  
+<a name="51" href="#51">51</a>      <em class="jxr_javadoccomment">/**</em>
+<a name="52" href="#52">52</a>  <em class="jxr_javadoccomment">     * Maximum number of bytes that can be stored in memory before</em>
+<a name="53" href="#53">53</a>  <em class="jxr_javadoccomment">     * storage will be moved to a temporary file.</em>
+<a name="54" href="#54">54</a>  <em class="jxr_javadoccomment">     */</em>
+<a name="55" href="#55">55</a>      <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">int</strong> maxBytesInMemory;
+<a name="56" href="#56">56</a>  
+<a name="57" href="#57">57</a>      <em class="jxr_javadoccomment">/**</em>
+<a name="58" href="#58">58</a>  <em class="jxr_javadoccomment">     * True when the original stream is being read; set to false when</em>
+<a name="59" href="#59">59</a>  <em class="jxr_javadoccomment">     * reading is set to use the stored data instead.</em>
+<a name="60" href="#60">60</a>  <em class="jxr_javadoccomment">     */</em>
+<a name="61" href="#61">61</a>      <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">boolean</strong> firstPass = <strong class="jxr_keyword">true</strong>;
+<a name="62" href="#62">62</a>  
+<a name="63" href="#63">63</a>      <em class="jxr_javadoccomment">/**</em>
+<a name="64" href="#64">64</a>  <em class="jxr_javadoccomment">     * Whether or not the stream's contents are being stored in a file</em>
+<a name="65" href="#65">65</a>  <em class="jxr_javadoccomment">     * as opposed to memory.</em>
+<a name="66" href="#66">66</a>  <em class="jxr_javadoccomment">     */</em>
+<a name="67" href="#67">67</a>      <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">boolean</strong> bufferIsInFile;
+<a name="68" href="#68">68</a>  
+<a name="69" href="#69">69</a>      <em class="jxr_javadoccomment">/**</em>
+<a name="70" href="#70">70</a>  <em class="jxr_javadoccomment">     * The buffer used to store the stream's content; this storage is moved</em>
+<a name="71" href="#71">71</a>  <em class="jxr_javadoccomment">     * to a file when the stored data's size exceeds maxBytesInMemory.</em>
+<a name="72" href="#72">72</a>  <em class="jxr_javadoccomment">     */</em>
+<a name="73" href="#73">73</a>      <strong class="jxr_keyword">private</strong> byte[] byteBuffer;
+<a name="74" href="#74">74</a>  
+<a name="75" href="#75">75</a>      <em class="jxr_javadoccomment">/**</em>
+<a name="76" href="#76">76</a>  <em class="jxr_javadoccomment">     * The total number of bytes read from the original stream at the time.</em>
+<a name="77" href="#77">77</a>  <em class="jxr_javadoccomment">     */</em>
+<a name="78" href="#78">78</a>      <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">int</strong> size;
+<a name="79" href="#79">79</a>  
+<a name="80" href="#80">80</a>      <em class="jxr_javadoccomment">/**</em>
+<a name="81" href="#81">81</a>  <em class="jxr_javadoccomment">     * File used to store the stream's contents; is null until the stored</em>
+<a name="82" href="#82">82</a>  <em class="jxr_javadoccomment">     * content's size exceeds maxBytesInMemory.</em>
+<a name="83" href="#83">83</a>  <em class="jxr_javadoccomment">     */</em>
+<a name="84" href="#84">84</a>      <strong class="jxr_keyword">private</strong> File storeFile;
+<a name="85" href="#85">85</a>  
+<a name="86" href="#86">86</a>      <em class="jxr_javadoccomment">/**</em>
+<a name="87" href="#87">87</a>  <em class="jxr_javadoccomment">     * OutputStream used to save the content of the input stream in a</em>
+<a name="88" href="#88">88</a>  <em class="jxr_javadoccomment">     * temporary file.</em>
+<a name="89" href="#89">89</a>  <em class="jxr_javadoccomment">     */</em>
+<a name="90" href="#90">90</a>      <strong class="jxr_keyword">private</strong> OutputStream storeOutputStream;
+<a name="91" href="#91">91</a>  
+<a name="92" href="#92">92</a>  
+<a name="93" href="#93">93</a>      <em class="jxr_javadoccomment">/**</em>
+<a name="94" href="#94">94</a>  <em class="jxr_javadoccomment">     * Specifies whether or not to read to the end of stream on first</em>
+<a name="95" href="#95">95</a>  <em class="jxr_javadoccomment">     * rewind.  This defaults to true.  If this is set to false,</em>
+<a name="96" href="#96">96</a>  <em class="jxr_javadoccomment">     * then the first time when rewind() is called, only those bytes</em>
+<a name="97" href="#97">97</a>  <em class="jxr_javadoccomment">     * already read from the original stream will be available from then on.</em>
+<a name="98" href="#98">98</a>  <em class="jxr_javadoccomment">     */</em>
+<a name="99" href="#99">99</a>      <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">boolean</strong> readToEndOfStreamOnFirstRewind = <strong class="jxr_keyword">true</strong>;
+<a name="100" href="#100">100</a> 
+<a name="101" href="#101">101</a> 
+<a name="102" href="#102">102</a>     <em class="jxr_javadoccomment">/**</em>
+<a name="103" href="#103">103</a> <em class="jxr_javadoccomment">     * Specifies whether or not to close the original input stream</em>
+<a name="104" href="#104">104</a> <em class="jxr_javadoccomment">     * when close() is called.  Defaults to true.</em>
+<a name="105" href="#105">105</a> <em class="jxr_javadoccomment">     */</em>
+<a name="106" href="#106">106</a>     <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">boolean</strong> closeOriginalStreamOnClose = <strong class="jxr_keyword">true</strong>;
+<a name="107" href="#107">107</a> 
+<a name="108" href="#108">108</a> 
+<a name="109" href="#109">109</a>     <em class="jxr_comment">// TODO: At some point it would be better to replace the current approach</em>
+<a name="110" href="#110">110</a>     <em class="jxr_comment">// (specifying the above) with more automated behavior.  The stream could</em>
+<a name="111" href="#111">111</a>     <em class="jxr_comment">// keep the original stream open until EOF was reached.  For example, if:</em>
+<a name="112" href="#112">112</a>     <em class="jxr_comment">//</em>
+<a name="113" href="#113">113</a>     <em class="jxr_comment">// the original stream is 10 bytes, and</em>
+<a name="114" href="#114">114</a>     <em class="jxr_comment">// only 2 bytes are read on the first pass</em>
+<a name="115" href="#115">115</a>     <em class="jxr_comment">// rewind() is called</em>
+<a name="116" href="#116">116</a>     <em class="jxr_comment">// 5 bytes are read</em>
+<a name="117" href="#117">117</a>     <em class="jxr_comment">//</em>
+<a name="118" href="#118">118</a>     <em class="jxr_comment">// In this case, this instance gets the first 2 from its store,</em>
+<a name="119" href="#119">119</a>     <em class="jxr_comment">// and the next 3 from the original stream, saving those additional 3</em>
+<a name="120" href="#120">120</a>     <em class="jxr_comment">// bytes in the store.  In this way, only the maximum number of bytes</em>
+<a name="121" href="#121">121</a>     <em class="jxr_comment">// ever needed must be saved in the store; unused bytes are never read.</em>
+<a name="122" href="#122">122</a>     <em class="jxr_comment">// The original stream is closed when EOF is reached, or when close()</em>
+<a name="123" href="#123">123</a>     <em class="jxr_comment">// is called, whichever comes first.  Using this approach eliminates</em>
+<a name="124" href="#124">124</a>     <em class="jxr_comment">// the need to specify the flag (though makes implementation more complex).</em>
+<a name="125" href="#125">125</a>     
+<a name="126" href="#126">126</a> 
+<a name="127" href="#127">127</a> 
+<a name="128" href="#128">128</a>     <em class="jxr_javadoccomment">/**</em>
+<a name="129" href="#129">129</a> <em class="jxr_javadoccomment">     * Creates a rereadable input stream.</em>
+<a name="130" href="#130">130</a> <em class="jxr_javadoccomment">     *</em>
+<a name="131" href="#131">131</a> <em class="jxr_javadoccomment">     * @param inputStream stream containing the source of data</em>
+<a name="132" href="#132">132</a> <em class="jxr_javadoccomment">     * @param maxBytesInMemory maximum number of bytes to use to store</em>
+<a name="133" href="#133">133</a> <em class="jxr_javadoccomment">     *     the stream's contents in memory before switching to disk; note that</em>
+<a name="134" href="#134">134</a> <em class="jxr_javadoccomment">     *     the instance will preallocate a byte array whose size is</em>
+<a name="135" href="#135">135</a> <em class="jxr_javadoccomment">     *     maxBytesInMemory.  This byte array will be made available for</em>
+<a name="136" href="#136">136</a> <em class="jxr_javadoccomment">     *     garbage collection (i.e. its reference set to null) when the</em>
+<a name="137" href="#137">137</a> <em class="jxr_javadoccomment">     *     content size exceeds the array's size, when close() is called, or</em>
+<a name="138" href="#138">138</a> <em class="jxr_javadoccomment">     *     when there are no more references to the instance.</em>
+<a name="139" href="#139">139</a> <em class="jxr_javadoccomment">     * @param readToEndOfStreamOnFirstRewind Specifies whether or not to</em>
+<a name="140" href="#140">140</a> <em class="jxr_javadoccomment">     *     read to the end of stream on first rewind.  If this is set to false,</em>
+<a name="141" href="#141">141</a> <em class="jxr_javadoccomment">     *     then when rewind() is first called, only those bytes already read</em>
+<a name="142" href="#142">142</a> <em class="jxr_javadoccomment">     *     from the original stream will be available from then on.</em>
+<a name="143" href="#143">143</a> <em class="jxr_javadoccomment">     */</em>
+<a name="144" href="#144">144</a>     <strong class="jxr_keyword">public</strong> <a href="../../../../org/apache/tika/utils/RereadableInputStream.html">RereadableInputStream</a>(InputStream inputStream, <strong class="jxr_keyword">int</strong> maxBytesInMemory,
+<a name="145" href="#145">145</a>             <strong class="jxr_keyword">boolean</strong> readToEndOfStreamOnFirstRewind,
+<a name="146" href="#146">146</a>             <strong class="jxr_keyword">boolean</strong> closeOriginalStreamOnClose) {
+<a name="147" href="#147">147</a>         <strong class="jxr_keyword">this</strong>.inputStream = inputStream;
+<a name="148" href="#148">148</a>         <strong class="jxr_keyword">this</strong>.originalInputStream = inputStream;
+<a name="149" href="#149">149</a>         <strong class="jxr_keyword">this</strong>.maxBytesInMemory = maxBytesInMemory;
+<a name="150" href="#150">150</a>         byteBuffer = <strong class="jxr_keyword">new</strong> byte[maxBytesInMemory];
+<a name="151" href="#151">151</a>         <strong class="jxr_keyword">this</strong>.readToEndOfStreamOnFirstRewind = readToEndOfStreamOnFirstRewind;
+<a name="152" href="#152">152</a>         <strong class="jxr_keyword">this</strong>.closeOriginalStreamOnClose = closeOriginalStreamOnClose;
+<a name="153" href="#153">153</a>     }
+<a name="154" href="#154">154</a> 
+<a name="155" href="#155">155</a>     <em class="jxr_javadoccomment">/**</em>
+<a name="156" href="#156">156</a> <em class="jxr_javadoccomment">     * Reads a byte from the stream, saving it in the store if it is being</em>
+<a name="157" href="#157">157</a> <em class="jxr_javadoccomment">     * read from the original stream.  Implements the abstract</em>
+<a name="158" href="#158">158</a> <em class="jxr_javadoccomment">     * InputStream.read().</em>
+<a name="159" href="#159">159</a> <em class="jxr_javadoccomment">     *</em>
+<a name="160" href="#160">160</a> <em class="jxr_javadoccomment">     * @return the read byte, or -1 on end of stream.</em>
+<a name="161" href="#161">161</a> <em class="jxr_javadoccomment">     * @throws IOException</em>
+<a name="162" href="#162">162</a> <em class="jxr_javadoccomment">     */</em>
+<a name="163" href="#163">163</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">int</strong> read() <strong class="jxr_keyword">throws</strong> IOException {
+<a name="164" href="#164">164</a>         <strong class="jxr_keyword">int</strong> inputByte = inputStream.read();
+<a name="165" href="#165">165</a>         <strong class="jxr_keyword">if</strong> (firstPass) {
+<a name="166" href="#166">166</a>             saveByte(inputByte);
+<a name="167" href="#167">167</a>         }
+<a name="168" href="#168">168</a>         <strong class="jxr_keyword">return</strong> inputByte;
+<a name="169" href="#169">169</a>     }
+<a name="170" href="#170">170</a> 
+<a name="171" href="#171">171</a>     <em class="jxr_javadoccomment">/**</em>
+<a name="172" href="#172">172</a> <em class="jxr_javadoccomment">     * "Rewinds" the stream to the beginning for rereading.</em>
+<a name="173" href="#173">173</a> <em class="jxr_javadoccomment">     * @throws IOException</em>
+<a name="174" href="#174">174</a> <em class="jxr_javadoccomment">     */</em>
+<a name="175" href="#175">175</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> rewind() <strong class="jxr_keyword">throws</strong> IOException {
+<a name="176" href="#176">176</a> 
+<a name="177" href="#177">177</a>         <strong class="jxr_keyword">if</strong> (firstPass &amp;&amp; readToEndOfStreamOnFirstRewind) {
+<a name="178" href="#178">178</a>             <em class="jxr_comment">// Force read to end of stream to fill store with any</em>
+<a name="179" href="#179">179</a>             <em class="jxr_comment">// remaining bytes from original stream.</em>
+<a name="180" href="#180">180</a>             <strong class="jxr_keyword">while</strong>(read() != -1) {
+<a name="181" href="#181">181</a>                 <em class="jxr_comment">// empty loop</em>
+<a name="182" href="#182">182</a>             }
+<a name="183" href="#183">183</a>         }
+<a name="184" href="#184">184</a> 
+<a name="185" href="#185">185</a>         closeStream();
+<a name="186" href="#186">186</a>         <strong class="jxr_keyword">if</strong> (storeOutputStream != <strong class="jxr_keyword">null</strong>) {
+<a name="187" href="#187">187</a>             storeOutputStream.close();
+<a name="188" href="#188">188</a>             storeOutputStream = <strong class="jxr_keyword">null</strong>;
+<a name="189" href="#189">189</a>         }
+<a name="190" href="#190">190</a>         firstPass = false;
+<a name="191" href="#191">191</a>         <strong class="jxr_keyword">boolean</strong> newStreamIsInMemory = (size &lt; maxBytesInMemory);
+<a name="192" href="#192">192</a>         inputStream = newStreamIsInMemory
+<a name="193" href="#193">193</a>                 ? <strong class="jxr_keyword">new</strong> ByteArrayInputStream(byteBuffer)
+<a name="194" href="#194">194</a>                 : <strong class="jxr_keyword">new</strong> BufferedInputStream(<strong class="jxr_keyword">new</strong> FileInputStream(storeFile));
+<a name="195" href="#195">195</a>     }
+<a name="196" href="#196">196</a> 
+<a name="197" href="#197">197</a>     <em class="jxr_javadoccomment">/**</em>
+<a name="198" href="#198">198</a> <em class="jxr_javadoccomment">     * Closes the input stream currently used for reading (may either be</em>
+<a name="199" href="#199">199</a> <em class="jxr_javadoccomment">     * the original stream or a memory or file stream after the first pass).</em>
+<a name="200" href="#200">200</a> <em class="jxr_javadoccomment">     *</em>
+<a name="201" href="#201">201</a> <em class="jxr_javadoccomment">     * @throws IOException</em>
+<a name="202" href="#202">202</a> <em class="jxr_javadoccomment">     */</em>
+<a name="203" href="#203">203</a>     <em class="jxr_comment">// Does anyone need/want for this to be public?</em>
+<a name="204" href="#204">204</a>     <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">void</strong> closeStream() <strong class="jxr_keyword">throws</strong> IOException {
+<a name="205" href="#205">205</a>         <strong class="jxr_keyword">if</strong> (inputStream != <strong class="jxr_keyword">null</strong>
+<a name="206" href="#206">206</a>                 &amp;&amp;
+<a name="207" href="#207">207</a>                 (inputStream != originalInputStream
+<a name="208" href="#208">208</a>                         || closeOriginalStreamOnClose)) {
+<a name="209" href="#209">209</a>             inputStream.close();
+<a name="210" href="#210">210</a>             inputStream = <strong class="jxr_keyword">null</strong>;
+<a name="211" href="#211">211</a>         }
+<a name="212" href="#212">212</a>     }
+<a name="213" href="#213">213</a> 
+<a name="214" href="#214">214</a>     <em class="jxr_javadoccomment">/**</em>
+<a name="215" href="#215">215</a> <em class="jxr_javadoccomment">     * Closes the input stream and removes the temporary file if one was</em>
+<a name="216" href="#216">216</a> <em class="jxr_javadoccomment">     * created.</em>
+<a name="217" href="#217">217</a> <em class="jxr_javadoccomment">     * </em>
+<a name="218" href="#218">218</a> <em class="jxr_javadoccomment">     * @throws IOException</em>
+<a name="219" href="#219">219</a> <em class="jxr_javadoccomment">     */</em>
+<a name="220" href="#220">220</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> close() <strong class="jxr_keyword">throws</strong> IOException {
+<a name="221" href="#221">221</a>         closeStream();
+<a name="222" href="#222">222</a>         <strong class="jxr_keyword">super</strong>.close();
+<a name="223" href="#223">223</a>         <strong class="jxr_keyword">if</strong> (storeFile != <strong class="jxr_keyword">null</strong>) {
+<a name="224" href="#224">224</a>             storeFile.delete();
+<a name="225" href="#225">225</a>         }
+<a name="226" href="#226">226</a>     }
+<a name="227" href="#227">227</a> 
+<a name="228" href="#228">228</a>     <em class="jxr_javadoccomment">/**</em>
+<a name="229" href="#229">229</a> <em class="jxr_javadoccomment">     * Returns the number of bytes read from the original stream.</em>
+<a name="230" href="#230">230</a> <em class="jxr_javadoccomment">     *</em>
+<a name="231" href="#231">231</a> <em class="jxr_javadoccomment">     * @return number of bytes read</em>
+<a name="232" href="#232">232</a> <em class="jxr_javadoccomment">     */</em>
+<a name="233" href="#233">233</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">int</strong> getSize() {
+<a name="234" href="#234">234</a>         <strong class="jxr_keyword">return</strong> size;
+<a name="235" href="#235">235</a>     }
+<a name="236" href="#236">236</a> 
+<a name="237" href="#237">237</a>     <em class="jxr_javadoccomment">/**</em>
+<a name="238" href="#238">238</a> <em class="jxr_javadoccomment">     * Saves the byte read from the original stream to the store.</em>
+<a name="239" href="#239">239</a> <em class="jxr_javadoccomment">     *</em>
+<a name="240" href="#240">240</a> <em class="jxr_javadoccomment">     * @param inputByte byte read from original stream</em>
+<a name="241" href="#241">241</a> <em class="jxr_javadoccomment">     * @throws IOException</em>
+<a name="242" href="#242">242</a> <em class="jxr_javadoccomment">     */</em>
+<a name="243" href="#243">243</a>     <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">void</strong> saveByte(<strong class="jxr_keyword">int</strong> inputByte) <strong class="jxr_keyword">throws</strong> IOException {
+<a name="244" href="#244">244</a> 
+<a name="245" href="#245">245</a>         <strong class="jxr_keyword">if</strong> (!bufferIsInFile) {
+<a name="246" href="#246">246</a>             <strong class="jxr_keyword">boolean</strong> switchToFile = (size == (maxBytesInMemory));
+<a name="247" href="#247">247</a>             <strong class="jxr_keyword">if</strong> (switchToFile) {
+<a name="248" href="#248">248</a>                 storeFile = File.createTempFile(<span class="jxr_string">"TIKA_streamstore_"</span>, <span class="jxr_string">".tmp"</span>);
+<a name="249" href="#249">249</a>                 bufferIsInFile = <strong class="jxr_keyword">true</strong>;
+<a name="250" href="#250">250</a>                 storeOutputStream = <strong class="jxr_keyword">new</strong> BufferedOutputStream(
+<a name="251" href="#251">251</a>                         <strong class="jxr_keyword">new</strong> FileOutputStream(storeFile));
+<a name="252" href="#252">252</a>                 storeOutputStream.write(byteBuffer, 0, size);
+<a name="253" href="#253">253</a>                 storeOutputStream.write(inputByte);
+<a name="254" href="#254">254</a>                 byteBuffer = <strong class="jxr_keyword">null</strong>; <em class="jxr_comment">// release for garbage collection</em>
+<a name="255" href="#255">255</a>             } <strong class="jxr_keyword">else</strong> {
+<a name="256" href="#256">256</a>                 byteBuffer[size] = (byte) inputByte;
+<a name="257" href="#257">257</a>             }
+<a name="258" href="#258">258</a>         } <strong class="jxr_keyword">else</strong> {
+<a name="259" href="#259">259</a>             storeOutputStream.write(inputByte);
+<a name="260" href="#260">260</a>         }
+<a name="261" href="#261">261</a>         ++size;
+<a name="262" href="#262">262</a>     }
+<a name="263" href="#263">263</a> }
+</pre>
+<hr/><div id="footer">This page was automatically generated by <a href="http://maven.apache.org/">Maven</a></div></body>
+</html>
+

Added: incubator/tika/site/xref/org/apache/tika/utils/StringUtil.html
URL: http://svn.apache.org/viewvc/incubator/tika/site/xref/org/apache/tika/utils/StringUtil.html?rev=596146&view=auto
==============================================================================
--- incubator/tika/site/xref/org/apache/tika/utils/StringUtil.html (added)
+++ incubator/tika/site/xref/org/apache/tika/utils/StringUtil.html Sun Nov 18 14:20:54 2007
@@ -0,0 +1,226 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
+<title>StringUtil xref</title>
+<link type="text/css" rel="stylesheet" href="../../../../stylesheet.css" />
+</head>
+<body>
+<div id="overview"><a href="../../../../../apidocs/org/apache/tika/utils/StringUtil.html">View Javadoc</a></div><pre>
+
+<a name="1" href="#1">1</a>   <em class="jxr_javadoccomment">/**</em>
+<a name="2" href="#2">2</a>   <em class="jxr_javadoccomment"> * Licensed to the Apache Software Foundation (ASF) under one or more</em>
+<a name="3" href="#3">3</a>   <em class="jxr_javadoccomment"> * contributor license agreements.  See the NOTICE file distributed with</em>
+<a name="4" href="#4">4</a>   <em class="jxr_javadoccomment"> * this work for additional information regarding copyright ownership.</em>
+<a name="5" href="#5">5</a>   <em class="jxr_javadoccomment"> * The ASF licenses this file to You under the Apache License, Version 2.0</em>
+<a name="6" href="#6">6</a>   <em class="jxr_javadoccomment"> * (the "License"); you may not use this file except in compliance with</em>
+<a name="7" href="#7">7</a>   <em class="jxr_javadoccomment"> * the License.  You may obtain a copy of the License at</em>
+<a name="8" href="#8">8</a>   <em class="jxr_javadoccomment"> *</em>
+<a name="9" href="#9">9</a>   <em class="jxr_javadoccomment"> *     <a href="http://www.apache.org/licenses/LICENSE-2.0" target="alexandria_uri">http://www.apache.org/licenses/LICENSE-2.0</a></em>
+<a name="10" href="#10">10</a>  <em class="jxr_javadoccomment"> *</em>
+<a name="11" href="#11">11</a>  <em class="jxr_javadoccomment"> * Unless required by applicable law or agreed to in writing, software</em>
+<a name="12" href="#12">12</a>  <em class="jxr_javadoccomment"> * distributed under the License is distributed on an "AS IS" BASIS,</em>
+<a name="13" href="#13">13</a>  <em class="jxr_javadoccomment"> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</em>
+<a name="14" href="#14">14</a>  <em class="jxr_javadoccomment"> * See the License for the specific language governing permissions and</em>
+<a name="15" href="#15">15</a>  <em class="jxr_javadoccomment"> * limitations under the License.</em>
+<a name="16" href="#16">16</a>  <em class="jxr_javadoccomment"> */</em>
+<a name="17" href="#17">17</a>  
+<a name="18" href="#18">18</a>  <strong class="jxr_keyword">package</strong> org.apache.tika.utils;
+<a name="19" href="#19">19</a>  
+<a name="20" href="#20">20</a>  <em class="jxr_comment">// JDK imports</em>
+<a name="21" href="#21">21</a>  <strong class="jxr_keyword">import</strong> java.util.HashMap;
+<a name="22" href="#22">22</a>  <strong class="jxr_keyword">import</strong> java.nio.charset.Charset;
+<a name="23" href="#23">23</a>  
+<a name="24" href="#24">24</a>  <em class="jxr_javadoccomment">/**</em>
+<a name="25" href="#25">25</a>  <em class="jxr_javadoccomment"> * A collection of String processing utility methods.</em>
+<a name="26" href="#26">26</a>  <em class="jxr_javadoccomment"> */</em>
+<a name="27" href="#27">27</a>  <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../org/apache/tika/utils/StringUtil.html">StringUtil</a> {
+<a name="28" href="#28">28</a>  
+<a name="29" href="#29">29</a>      <em class="jxr_javadoccomment">/**</em>
+<a name="30" href="#30">30</a>  <em class="jxr_javadoccomment">     * Returns a copy of &lt;code&gt;s&lt;/code&gt; padded with trailing spaces so that</em>
+<a name="31" href="#31">31</a>  <em class="jxr_javadoccomment">     * it's length is &lt;code&gt;length&lt;/code&gt;. Strings already</em>
+<a name="32" href="#32">32</a>  <em class="jxr_javadoccomment">     * &lt;code&gt;length&lt;/code&gt; characters long or longer are not altered.</em>
+<a name="33" href="#33">33</a>  <em class="jxr_javadoccomment">     */</em>
+<a name="34" href="#34">34</a>      <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> String rightPad(String s, <strong class="jxr_keyword">int</strong> length) {
+<a name="35" href="#35">35</a>          StringBuffer sb = <strong class="jxr_keyword">new</strong> StringBuffer(s);
+<a name="36" href="#36">36</a>          <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i = length - s.length(); i &gt; 0; i--)
+<a name="37" href="#37">37</a>              sb.append(<span class="jxr_string">" "</span>);
+<a name="38" href="#38">38</a>          <strong class="jxr_keyword">return</strong> sb.toString();
+<a name="39" href="#39">39</a>      }
+<a name="40" href="#40">40</a>  
+<a name="41" href="#41">41</a>      <em class="jxr_javadoccomment">/**</em>
+<a name="42" href="#42">42</a>  <em class="jxr_javadoccomment">     * Returns a copy of &lt;code&gt;s&lt;/code&gt; padded with leading spaces so that</em>
+<a name="43" href="#43">43</a>  <em class="jxr_javadoccomment">     * it's length is &lt;code&gt;length&lt;/code&gt;. Strings already</em>
+<a name="44" href="#44">44</a>  <em class="jxr_javadoccomment">     * &lt;code&gt;length&lt;/code&gt; characters long or longer are not altered.</em>
+<a name="45" href="#45">45</a>  <em class="jxr_javadoccomment">     */</em>
+<a name="46" href="#46">46</a>      <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> String leftPad(String s, <strong class="jxr_keyword">int</strong> length) {
+<a name="47" href="#47">47</a>          StringBuffer sb = <strong class="jxr_keyword">new</strong> StringBuffer();
+<a name="48" href="#48">48</a>          <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i = length - s.length(); i &gt; 0; i--)
+<a name="49" href="#49">49</a>              sb.append(<span class="jxr_string">" "</span>);
+<a name="50" href="#50">50</a>          sb.append(s);
+<a name="51" href="#51">51</a>          <strong class="jxr_keyword">return</strong> sb.toString();
+<a name="52" href="#52">52</a>      }
+<a name="53" href="#53">53</a>  
+<a name="54" href="#54">54</a>      <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">char</strong>[] HEX_DIGITS = { '0', '1', '2', '3', '4', '5',
+<a name="55" href="#55">55</a>              '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
+<a name="56" href="#56">56</a>  
+<a name="57" href="#57">57</a>      <em class="jxr_javadoccomment">/**</em>
+<a name="58" href="#58">58</a>  <em class="jxr_javadoccomment">     * Convenience call for {@link #toHexString(byte[], String, int)}, where</em>
+<a name="59" href="#59">59</a>  <em class="jxr_javadoccomment">     * &lt;code&gt;sep = null; lineLen = Integer.MAX_VALUE&lt;/code&gt;.</em>
+<a name="60" href="#60">60</a>  <em class="jxr_javadoccomment">     * </em>
+<a name="61" href="#61">61</a>  <em class="jxr_javadoccomment">     * @param buf</em>
+<a name="62" href="#62">62</a>  <em class="jxr_javadoccomment">     */</em>
+<a name="63" href="#63">63</a>      <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> String toHexString(byte[] buf) {
+<a name="64" href="#64">64</a>          <strong class="jxr_keyword">return</strong> toHexString(buf, <strong class="jxr_keyword">null</strong>, Integer.MAX_VALUE);
+<a name="65" href="#65">65</a>      }
+<a name="66" href="#66">66</a>  
+<a name="67" href="#67">67</a>      <em class="jxr_javadoccomment">/**</em>
+<a name="68" href="#68">68</a>  <em class="jxr_javadoccomment">     * Get a text representation of a byte[] as hexadecimal String, where each</em>
+<a name="69" href="#69">69</a>  <em class="jxr_javadoccomment">     * pair of hexadecimal digits corresponds to consecutive bytes in the array.</em>
+<a name="70" href="#70">70</a>  <em class="jxr_javadoccomment">     * </em>
+<a name="71" href="#71">71</a>  <em class="jxr_javadoccomment">     * @param buf</em>
+<a name="72" href="#72">72</a>  <em class="jxr_javadoccomment">     *            input data</em>
+<a name="73" href="#73">73</a>  <em class="jxr_javadoccomment">     * @param sep</em>
+<a name="74" href="#74">74</a>  <em class="jxr_javadoccomment">     *            separate every pair of hexadecimal digits with this separator,</em>
+<a name="75" href="#75">75</a>  <em class="jxr_javadoccomment">     *            or null if no separation is needed.</em>
+<a name="76" href="#76">76</a>  <em class="jxr_javadoccomment">     * @param lineLen</em>
+<a name="77" href="#77">77</a>  <em class="jxr_javadoccomment">     *            break the output String into lines containing output for</em>
+<a name="78" href="#78">78</a>  <em class="jxr_javadoccomment">     *            lineLen bytes.</em>
+<a name="79" href="#79">79</a>  <em class="jxr_javadoccomment">     */</em>
+<a name="80" href="#80">80</a>      <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> String toHexString(byte[] buf, String sep, <strong class="jxr_keyword">int</strong> lineLen) {
+<a name="81" href="#81">81</a>          <strong class="jxr_keyword">if</strong> (buf == <strong class="jxr_keyword">null</strong>)
+<a name="82" href="#82">82</a>              <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>;
+<a name="83" href="#83">83</a>          <strong class="jxr_keyword">if</strong> (lineLen &lt;= 0)
+<a name="84" href="#84">84</a>              lineLen = Integer.MAX_VALUE;
+<a name="85" href="#85">85</a>          StringBuffer res = <strong class="jxr_keyword">new</strong> StringBuffer(buf.length * 2);
+<a name="86" href="#86">86</a>          <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i = 0; i &lt; buf.length; i++) {
+<a name="87" href="#87">87</a>              <strong class="jxr_keyword">int</strong> b = buf[i];
+<a name="88" href="#88">88</a>              res.append(HEX_DIGITS[(b &gt;&gt; 4) &amp; 0xf]);
+<a name="89" href="#89">89</a>              res.append(HEX_DIGITS[b &amp; 0xf]);
+<a name="90" href="#90">90</a>              <strong class="jxr_keyword">if</strong> (i &gt; 0 &amp;&amp; (i % lineLen) == 0)
+<a name="91" href="#91">91</a>                  res.append('\n');
+<a name="92" href="#92">92</a>              <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (sep != <strong class="jxr_keyword">null</strong> &amp;&amp; i &lt; lineLen - 1)
+<a name="93" href="#93">93</a>                  res.append(sep);
+<a name="94" href="#94">94</a>          }
+<a name="95" href="#95">95</a>          <strong class="jxr_keyword">return</strong> res.toString();
+<a name="96" href="#96">96</a>      }
+<a name="97" href="#97">97</a>  
+<a name="98" href="#98">98</a>      <em class="jxr_javadoccomment">/**</em>
+<a name="99" href="#99">99</a>  <em class="jxr_javadoccomment">     * Convert a String containing consecutive (no inside whitespace)</em>
+<a name="100" href="#100">100</a> <em class="jxr_javadoccomment">     * hexadecimal digits into a corresponding byte array. If the number of</em>
+<a name="101" href="#101">101</a> <em class="jxr_javadoccomment">     * digits is not even, a '0' will be appended in the front of the String</em>
+<a name="102" href="#102">102</a> <em class="jxr_javadoccomment">     * prior to conversion. Leading and trailing whitespace is ignored.</em>
+<a name="103" href="#103">103</a> <em class="jxr_javadoccomment">     * </em>
+<a name="104" href="#104">104</a> <em class="jxr_javadoccomment">     * @param text</em>
+<a name="105" href="#105">105</a> <em class="jxr_javadoccomment">     *            input text</em>
+<a name="106" href="#106">106</a> <em class="jxr_javadoccomment">     * @return converted byte array, or null if unable to convert</em>
+<a name="107" href="#107">107</a> <em class="jxr_javadoccomment">     */</em>
+<a name="108" href="#108">108</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> byte[] fromHexString(String text) {
+<a name="109" href="#109">109</a>         text = text.trim();
+<a name="110" href="#110">110</a>         <strong class="jxr_keyword">if</strong> (text.length() % 2 != 0)
+<a name="111" href="#111">111</a>             text = <span class="jxr_string">"0"</span> + text;
+<a name="112" href="#112">112</a>         <strong class="jxr_keyword">int</strong> resLen = text.length() / 2;
+<a name="113" href="#113">113</a>         <strong class="jxr_keyword">int</strong> loNibble, hiNibble;
+<a name="114" href="#114">114</a>         byte[] res = <strong class="jxr_keyword">new</strong> byte[resLen];
+<a name="115" href="#115">115</a>         <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i = 0; i &lt; resLen; i++) {
+<a name="116" href="#116">116</a>             <strong class="jxr_keyword">int</strong> j = i &lt;&lt; 1;
+<a name="117" href="#117">117</a>             hiNibble = charToNibble(text.charAt(j));
+<a name="118" href="#118">118</a>             loNibble = charToNibble(text.charAt(j + 1));
+<a name="119" href="#119">119</a>             <strong class="jxr_keyword">if</strong> (loNibble == -1 || hiNibble == -1)
+<a name="120" href="#120">120</a>                 <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>;
+<a name="121" href="#121">121</a>             res[i] = (byte) (hiNibble &lt;&lt; 4 | loNibble);
+<a name="122" href="#122">122</a>         }
+<a name="123" href="#123">123</a>         <strong class="jxr_keyword">return</strong> res;
+<a name="124" href="#124">124</a>     }
+<a name="125" href="#125">125</a> 
+<a name="126" href="#126">126</a>     <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">int</strong> charToNibble(<strong class="jxr_keyword">char</strong> c) {
+<a name="127" href="#127">127</a>         <strong class="jxr_keyword">if</strong> (c &gt;= '0' &amp;&amp; c &lt;= '9') {
+<a name="128" href="#128">128</a>             <strong class="jxr_keyword">return</strong> c - '0';
+<a name="129" href="#129">129</a>         } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (c &gt;= 'a' &amp;&amp; c &lt;= 'f') {
+<a name="130" href="#130">130</a>             <strong class="jxr_keyword">return</strong> 0xa + (c - 'a');
+<a name="131" href="#131">131</a>         } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (c &gt;= 'A' &amp;&amp; c &lt;= 'F') {
+<a name="132" href="#132">132</a>             <strong class="jxr_keyword">return</strong> 0xA + (c - 'A');
+<a name="133" href="#133">133</a>         } <strong class="jxr_keyword">else</strong> {
+<a name="134" href="#134">134</a>             <strong class="jxr_keyword">return</strong> -1;
+<a name="135" href="#135">135</a>         }
+<a name="136" href="#136">136</a>     }
+<a name="137" href="#137">137</a> 
+<a name="138" href="#138">138</a>     <em class="jxr_javadoccomment">/**</em>
+<a name="139" href="#139">139</a> <em class="jxr_javadoccomment">     * Parse the character encoding from the specified content type header. If</em>
+<a name="140" href="#140">140</a> <em class="jxr_javadoccomment">     * the content type is null, or there is no explicit character encoding,</em>
+<a name="141" href="#141">141</a> <em class="jxr_javadoccomment">     * &lt;code&gt;null&lt;/code&gt; is returned. &lt;br /&gt;</em>
+<a name="142" href="#142">142</a> <em class="jxr_javadoccomment">     * This method was copy from org.apache.catalina.util.RequestUtil is</em>
+<a name="143" href="#143">143</a> <em class="jxr_javadoccomment">     * licensed under the Apache License, Version 2.0 (the "License").</em>
+<a name="144" href="#144">144</a> <em class="jxr_javadoccomment">     * </em>
+<a name="145" href="#145">145</a> <em class="jxr_javadoccomment">     * @param contentType</em>
+<a name="146" href="#146">146</a> <em class="jxr_javadoccomment">     *            a content type header</em>
+<a name="147" href="#147">147</a> <em class="jxr_javadoccomment">     */</em>
+<a name="148" href="#148">148</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> String parseCharacterEncoding(String contentType) {
+<a name="149" href="#149">149</a>         <strong class="jxr_keyword">if</strong> (contentType == <strong class="jxr_keyword">null</strong>)
+<a name="150" href="#150">150</a>             <strong class="jxr_keyword">return</strong> (<strong class="jxr_keyword">null</strong>);
+<a name="151" href="#151">151</a>         <strong class="jxr_keyword">int</strong> start = contentType.indexOf(<span class="jxr_string">"charset="</span>);
+<a name="152" href="#152">152</a>         <strong class="jxr_keyword">if</strong> (start &lt; 0)
+<a name="153" href="#153">153</a>             <strong class="jxr_keyword">return</strong> (<strong class="jxr_keyword">null</strong>);
+<a name="154" href="#154">154</a>         String encoding = contentType.substring(start + 8);
+<a name="155" href="#155">155</a>         <strong class="jxr_keyword">int</strong> end = encoding.indexOf(';');
+<a name="156" href="#156">156</a>         <strong class="jxr_keyword">if</strong> (end &gt;= 0)
+<a name="157" href="#157">157</a>             encoding = encoding.substring(0, end);
+<a name="158" href="#158">158</a>         encoding = encoding.trim();
+<a name="159" href="#159">159</a>         <strong class="jxr_keyword">if</strong> ((encoding.length() &gt; 2) &amp;&amp; (encoding.startsWith(<span class="jxr_string">"\&quot;"</span>))
+<a name="160" href="#160">160</a>                 &amp;&amp; (encoding.endsWith(<span class="jxr_string">"\&quot;"</span>)))
+<a name="161" href="#161">161</a>             encoding = encoding.substring(1, encoding.length() - 1);
+<a name="162" href="#162">162</a>         <strong class="jxr_keyword">return</strong> (encoding.trim());
+<a name="163" href="#163">163</a> 
+<a name="164" href="#164">164</a>     }
+<a name="165" href="#165">165</a> 
+<a name="166" href="#166">166</a>     <em class="jxr_javadoccomment">/**</em>
+<a name="167" href="#167">167</a> <em class="jxr_javadoccomment">     * Checks if a string is empty (ie is null or empty).</em>
+<a name="168" href="#168">168</a> <em class="jxr_javadoccomment">     */</em>
+<a name="169" href="#169">169</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">boolean</strong> isEmpty(String str) {
+<a name="170" href="#170">170</a>         <strong class="jxr_keyword">return</strong> (str == <strong class="jxr_keyword">null</strong>) || (str.equals(<span class="jxr_string">""</span>));
+<a name="171" href="#171">171</a>     }
+<a name="172" href="#172">172</a> 
+<a name="173" href="#173">173</a>     <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> HashMap encodingAliases = <strong class="jxr_keyword">new</strong> HashMap();
+<a name="174" href="#174">174</a> 
+<a name="175" href="#175">175</a>     <em class="jxr_javadoccomment">/**</em>
+<a name="176" href="#176">176</a> <em class="jxr_javadoccomment">     * the following map is not an alias mapping table, but maps character</em>
+<a name="177" href="#177">177</a> <em class="jxr_javadoccomment">     * encodings which are often used in mislabelled documents to their correct</em>
+<a name="178" href="#178">178</a> <em class="jxr_javadoccomment">     * encodings. For instance, there are a lot of documents labelled</em>
+<a name="179" href="#179">179</a> <em class="jxr_javadoccomment">     * 'ISO-8859-1' which contain characters not covered by ISO-8859-1 but</em>
+<a name="180" href="#180">180</a> <em class="jxr_javadoccomment">     * covered by windows-1252. Because windows-1252 is a superset of ISO-8859-1</em>
+<a name="181" href="#181">181</a> <em class="jxr_javadoccomment">     * (sharing code points for the common part), it's better to treat</em>
+<a name="182" href="#182">182</a> <em class="jxr_javadoccomment">     * ISO-8859-1 as synonymous with windows-1252 than to reject, as invalid,</em>
+<a name="183" href="#183">183</a> <em class="jxr_javadoccomment">     * documents labelled as ISO-8859-1 that have characters outside ISO-8859-1.</em>
+<a name="184" href="#184">184</a> <em class="jxr_javadoccomment">     */</em>
+<a name="185" href="#185">185</a>     <strong class="jxr_keyword">static</strong> {
+<a name="186" href="#186">186</a>         encodingAliases.put(<span class="jxr_string">"ISO-8859-1"</span>, <span class="jxr_string">"windows-1252"</span>);
+<a name="187" href="#187">187</a>         encodingAliases.put(<span class="jxr_string">"EUC-KR"</span>, <span class="jxr_string">"x-windows-949"</span>);
+<a name="188" href="#188">188</a>         encodingAliases.put(<span class="jxr_string">"x-EUC-CN"</span>, <span class="jxr_string">"GB18030"</span>);
+<a name="189" href="#189">189</a>         encodingAliases.put(<span class="jxr_string">"GBK"</span>, <span class="jxr_string">"GB18030"</span>);
+<a name="190" href="#190">190</a>         <em class="jxr_comment">// encodingAliases.put("Big5", "Big5HKSCS");</em>
+<a name="191" href="#191">191</a>         <em class="jxr_comment">// encodingAliases.put("TIS620", "Cp874");</em>
+<a name="192" href="#192">192</a>         <em class="jxr_comment">// encodingAliases.put("ISO-8859-11", "Cp874");</em>
+<a name="193" href="#193">193</a> 
+<a name="194" href="#194">194</a>     }
+<a name="195" href="#195">195</a> 
+<a name="196" href="#196">196</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> String resolveEncodingAlias(String encoding) {
+<a name="197" href="#197">197</a>         <strong class="jxr_keyword">if</strong> (!Charset.isSupported(encoding))
+<a name="198" href="#198">198</a>             <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>;
+<a name="199" href="#199">199</a>         String canonicalName = <strong class="jxr_keyword">new</strong> String(Charset.forName(encoding).name());
+<a name="200" href="#200">200</a>         <strong class="jxr_keyword">return</strong> encodingAliases.containsKey(canonicalName) ? (String) encodingAliases
+<a name="201" href="#201">201</a>                 .get(canonicalName)
+<a name="202" href="#202">202</a>                 : canonicalName;
+<a name="203" href="#203">203</a>     }
+<a name="204" href="#204">204</a> 
+<a name="205" href="#205">205</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">void</strong> main(String[] args) {
+<a name="206" href="#206">206</a>         <strong class="jxr_keyword">if</strong> (args.length != 1)
+<a name="207" href="#207">207</a>             System.out.println(<span class="jxr_string">"Usage: StringUtil &lt;encoding name&gt;"</span>);
+<a name="208" href="#208">208</a>         <strong class="jxr_keyword">else</strong>
+<a name="209" href="#209">209</a>             System.out.println(args[0] + <span class="jxr_string">" is resolved to "</span>
+<a name="210" href="#210">210</a>                     + resolveEncodingAlias(args[0]));
+<a name="211" href="#211">211</a>     }
+<a name="212" href="#212">212</a> }
+</pre>
+<hr/><div id="footer">This page was automatically generated by <a href="http://maven.apache.org/">Maven</a></div></body>
+</html>
+

Added: incubator/tika/site/xref/org/apache/tika/utils/Utils.html
URL: http://svn.apache.org/viewvc/incubator/tika/site/xref/org/apache/tika/utils/Utils.html?rev=596146&view=auto
==============================================================================
--- incubator/tika/site/xref/org/apache/tika/utils/Utils.html (added)
+++ incubator/tika/site/xref/org/apache/tika/utils/Utils.html Sun Nov 18 14:20:54 2007
@@ -0,0 +1,187 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
+<title>Utils xref</title>
+<link type="text/css" rel="stylesheet" href="../../../../stylesheet.css" />
+</head>
+<body>
+<div id="overview"><a href="../../../../../apidocs/org/apache/tika/utils/Utils.html">View Javadoc</a></div><pre>
+
+<a name="1" href="#1">1</a>   <em class="jxr_javadoccomment">/**</em>
+<a name="2" href="#2">2</a>   <em class="jxr_javadoccomment"> * Licensed to the Apache Software Foundation (ASF) under one or more</em>
+<a name="3" href="#3">3</a>   <em class="jxr_javadoccomment"> * contributor license agreements.  See the NOTICE file distributed with</em>
+<a name="4" href="#4">4</a>   <em class="jxr_javadoccomment"> * this work for additional information regarding copyright ownership.</em>
+<a name="5" href="#5">5</a>   <em class="jxr_javadoccomment"> * The ASF licenses this file to You under the Apache License, Version 2.0</em>
+<a name="6" href="#6">6</a>   <em class="jxr_javadoccomment"> * (the "License"); you may not use this file except in compliance with</em>
+<a name="7" href="#7">7</a>   <em class="jxr_javadoccomment"> * the License.  You may obtain a copy of the License at</em>
+<a name="8" href="#8">8</a>   <em class="jxr_javadoccomment"> *</em>
+<a name="9" href="#9">9</a>   <em class="jxr_javadoccomment"> *     <a href="http://www.apache.org/licenses/LICENSE-2.0" target="alexandria_uri">http://www.apache.org/licenses/LICENSE-2.0</a></em>
+<a name="10" href="#10">10</a>  <em class="jxr_javadoccomment"> *</em>
+<a name="11" href="#11">11</a>  <em class="jxr_javadoccomment"> * Unless required by applicable law or agreed to in writing, software</em>
+<a name="12" href="#12">12</a>  <em class="jxr_javadoccomment"> * distributed under the License is distributed on an "AS IS" BASIS,</em>
+<a name="13" href="#13">13</a>  <em class="jxr_javadoccomment"> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</em>
+<a name="14" href="#14">14</a>  <em class="jxr_javadoccomment"> * See the License for the specific language governing permissions and</em>
+<a name="15" href="#15">15</a>  <em class="jxr_javadoccomment"> * limitations under the License.</em>
+<a name="16" href="#16">16</a>  <em class="jxr_javadoccomment"> */</em>
+<a name="17" href="#17">17</a>  <strong class="jxr_keyword">package</strong> org.apache.tika.utils;
+<a name="18" href="#18">18</a>  
+<a name="19" href="#19">19</a>  <strong class="jxr_keyword">import</strong> java.io.BufferedInputStream;
+<a name="20" href="#20">20</a>  <strong class="jxr_keyword">import</strong> java.io.BufferedOutputStream;
+<a name="21" href="#21">21</a>  <strong class="jxr_keyword">import</strong> java.io.ByteArrayInputStream;
+<a name="22" href="#22">22</a>  <strong class="jxr_keyword">import</strong> java.io.ByteArrayOutputStream;
+<a name="23" href="#23">23</a>  <strong class="jxr_keyword">import</strong> java.io.File;
+<a name="24" href="#24">24</a>  <strong class="jxr_keyword">import</strong> java.io.FileOutputStream;
+<a name="25" href="#25">25</a>  <strong class="jxr_keyword">import</strong> java.io.IOException;
+<a name="26" href="#26">26</a>  <strong class="jxr_keyword">import</strong> java.io.InputStream;
+<a name="27" href="#27">27</a>  <strong class="jxr_keyword">import</strong> java.io.OutputStream;
+<a name="28" href="#28">28</a>  <strong class="jxr_keyword">import</strong> java.io.Reader;
+<a name="29" href="#29">29</a>  <strong class="jxr_keyword">import</strong> java.util.ArrayList;
+<a name="30" href="#30">30</a>  <strong class="jxr_keyword">import</strong> java.util.List;
+<a name="31" href="#31">31</a>  <strong class="jxr_keyword">import</strong> java.util.zip.ZipEntry;
+<a name="32" href="#32">32</a>  <strong class="jxr_keyword">import</strong> java.util.zip.ZipInputStream;
+<a name="33" href="#33">33</a>  
+<a name="34" href="#34">34</a>  <strong class="jxr_keyword">import</strong> org.apache.log4j.Logger;
+<a name="35" href="#35">35</a>  <strong class="jxr_keyword">import</strong> org.apache.tika.exception.TikaException;
+<a name="36" href="#36">36</a>  <strong class="jxr_keyword">import</strong> org.apache.tika.metadata.HttpHeaders;
+<a name="37" href="#37">37</a>  <strong class="jxr_keyword">import</strong> org.apache.tika.metadata.Metadata;
+<a name="38" href="#38">38</a>  <strong class="jxr_keyword">import</strong> org.jdom.Document;
+<a name="39" href="#39">39</a>  <strong class="jxr_keyword">import</strong> org.jdom.JDOMException;
+<a name="40" href="#40">40</a>  <strong class="jxr_keyword">import</strong> org.jdom.input.SAXBuilder;
+<a name="41" href="#41">41</a>  <strong class="jxr_keyword">import</strong> org.jdom.output.Format;
+<a name="42" href="#42">42</a>  <strong class="jxr_keyword">import</strong> org.jdom.output.XMLOutputter;
+<a name="43" href="#43">43</a>  
+<a name="44" href="#44">44</a>  <strong class="jxr_keyword">import</strong> com.ibm.icu.text.CharsetDetector;
+<a name="45" href="#45">45</a>  <strong class="jxr_keyword">import</strong> com.ibm.icu.text.CharsetMatch;
+<a name="46" href="#46">46</a>  
+<a name="47" href="#47">47</a>  <em class="jxr_javadoccomment">/**</em>
+<a name="48" href="#48">48</a>  <em class="jxr_javadoccomment"> * Class util</em>
+<a name="49" href="#49">49</a>  <em class="jxr_javadoccomment"> * </em>
+<a name="50" href="#50">50</a>  <em class="jxr_javadoccomment"> * </em>
+<a name="51" href="#51">51</a>  <em class="jxr_javadoccomment"> */</em>
+<a name="52" href="#52">52</a>  
+<a name="53" href="#53">53</a>  <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../org/apache/tika/utils/Utils.html">Utils</a> {
+<a name="54" href="#54">54</a>  
+<a name="55" href="#55">55</a>      <strong class="jxr_keyword">static</strong> Logger logger = Logger.getRootLogger();
+<a name="56" href="#56">56</a>  
+<a name="57" href="#57">57</a>      <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> Document parse(InputStream is) {
+<a name="58" href="#58">58</a>          org.jdom.Document xmlDoc = <strong class="jxr_keyword">new</strong> org.jdom.Document();
+<a name="59" href="#59">59</a>          <strong class="jxr_keyword">try</strong> {
+<a name="60" href="#60">60</a>              SAXBuilder builder = <strong class="jxr_keyword">new</strong> SAXBuilder();
+<a name="61" href="#61">61</a>              builder.setValidation(false);
+<a name="62" href="#62">62</a>              xmlDoc = builder.build(is);
+<a name="63" href="#63">63</a>          } <strong class="jxr_keyword">catch</strong> (JDOMException e) {
+<a name="64" href="#64">64</a>              logger.error(e.getMessage());
+<a name="65" href="#65">65</a>          } <strong class="jxr_keyword">catch</strong> (IOException e) {
+<a name="66" href="#66">66</a>              logger.error(e.getMessage());
+<a name="67" href="#67">67</a>          }
+<a name="68" href="#68">68</a>          <strong class="jxr_keyword">return</strong> xmlDoc;
+<a name="69" href="#69">69</a>      }
+<a name="70" href="#70">70</a>  
+<a name="71" href="#71">71</a>      <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> List unzip(InputStream is) {
+<a name="72" href="#72">72</a>          List res = <strong class="jxr_keyword">new</strong> ArrayList();
+<a name="73" href="#73">73</a>          <strong class="jxr_keyword">try</strong> {
+<a name="74" href="#74">74</a>              ZipInputStream in = <strong class="jxr_keyword">new</strong> ZipInputStream(is);
+<a name="75" href="#75">75</a>              ZipEntry entry = <strong class="jxr_keyword">null</strong>;
+<a name="76" href="#76">76</a>              <strong class="jxr_keyword">while</strong> ((entry = in.getNextEntry()) != <strong class="jxr_keyword">null</strong>) {
+<a name="77" href="#77">77</a>                  ByteArrayOutputStream stream = <strong class="jxr_keyword">new</strong> ByteArrayOutputStream();
+<a name="78" href="#78">78</a>                  byte[] buf = <strong class="jxr_keyword">new</strong> byte[1024];
+<a name="79" href="#79">79</a>                  <strong class="jxr_keyword">int</strong> len;
+<a name="80" href="#80">80</a>                  <strong class="jxr_keyword">while</strong> ((len = in.read(buf)) &gt; 0) {
+<a name="81" href="#81">81</a>                      stream.write(buf, 0, len);
+<a name="82" href="#82">82</a>                  }
+<a name="83" href="#83">83</a>                  InputStream isEntry = <strong class="jxr_keyword">new</strong> ByteArrayInputStream(stream
+<a name="84" href="#84">84</a>                          .toByteArray());
+<a name="85" href="#85">85</a>                  File file = File.createTempFile(<span class="jxr_string">"TIKA_unzip_"</span>, <span class="jxr_string">"_"</span> + entry.getName());
+<a name="86" href="#86">86</a>                  
+<a name="87" href="#87">87</a>                  <em class="jxr_comment">// TODO we might want to delete the file earlier than on exit,</em>
+<a name="88" href="#88">88</a>                  <em class="jxr_comment">// in case Tika is used inside a long-running app</em>
+<a name="89" href="#89">89</a>                  file.deleteOnExit();
+<a name="90" href="#90">90</a>                  saveInputStreamInFile(isEntry, <strong class="jxr_keyword">new</strong> BufferedOutputStream(
+<a name="91" href="#91">91</a>                          <strong class="jxr_keyword">new</strong> FileOutputStream(file)));
+<a name="92" href="#92">92</a>                  res.add(file);
+<a name="93" href="#93">93</a>                  isEntry.close();
+<a name="94" href="#94">94</a>              }
+<a name="95" href="#95">95</a>              in.close();
+<a name="96" href="#96">96</a>          } <strong class="jxr_keyword">catch</strong> (IOException e) {
+<a name="97" href="#97">97</a>              logger.error(e.getMessage());
+<a name="98" href="#98">98</a>          }
+<a name="99" href="#99">99</a>          <strong class="jxr_keyword">return</strong> res;
+<a name="100" href="#100">100</a>     }
+<a name="101" href="#101">101</a> 
+<a name="102" href="#102">102</a>     <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">void</strong> saveInputStreamInFile(InputStream in, OutputStream out)
+<a name="103" href="#103">103</a>             <strong class="jxr_keyword">throws</strong> IOException {
+<a name="104" href="#104">104</a>         byte[] buffer = <strong class="jxr_keyword">new</strong> byte[1024];
+<a name="105" href="#105">105</a>         <strong class="jxr_keyword">int</strong> len;
+<a name="106" href="#106">106</a> 
+<a name="107" href="#107">107</a>         <strong class="jxr_keyword">while</strong> ((len = in.read(buffer)) &gt;= 0)
+<a name="108" href="#108">108</a>             out.write(buffer, 0, len);
+<a name="109" href="#109">109</a> 
+<a name="110" href="#110">110</a>         in.close();
+<a name="111" href="#111">111</a>         out.close();
+<a name="112" href="#112">112</a>     }
+<a name="113" href="#113">113</a> 
+<a name="114" href="#114">114</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">void</strong> saveInXmlFile(Document doc, String file) {
+<a name="115" href="#115">115</a>         Format f = Format.getPrettyFormat().setEncoding(<span class="jxr_string">"UTF-8"</span>);
+<a name="116" href="#116">116</a> 
+<a name="117" href="#117">117</a>         XMLOutputter xop = <strong class="jxr_keyword">new</strong> XMLOutputter(f);
+<a name="118" href="#118">118</a> 
+<a name="119" href="#119">119</a>         <strong class="jxr_keyword">try</strong> {
+<a name="120" href="#120">120</a> 
+<a name="121" href="#121">121</a>             xop.output(doc, <strong class="jxr_keyword">new</strong> FileOutputStream(file));
+<a name="122" href="#122">122</a> 
+<a name="123" href="#123">123</a>         }
+<a name="124" href="#124">124</a> 
+<a name="125" href="#125">125</a>         <strong class="jxr_keyword">catch</strong> (IOException ex) {
+<a name="126" href="#126">126</a> 
+<a name="127" href="#127">127</a>             logger.error(ex.getMessage());
+<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> 
+<a name="132" href="#132">132</a>     <em class="jxr_javadoccomment">/**</em>
+<a name="133" href="#133">133</a> <em class="jxr_javadoccomment">     * Try to detect encoding from inputstream and return a UTF-8</em>
+<a name="134" href="#134">134</a> <em class="jxr_javadoccomment">     * Reader. A metadata hint can be submitted as part of {@link Metadata}</em>
+<a name="135" href="#135">135</a> <em class="jxr_javadoccomment">     * under key {@link HttpHeaders#CONTENT_ENCODING}.</em>
+<a name="136" href="#136">136</a> <em class="jxr_javadoccomment">     * </em>
+<a name="137" href="#137">137</a> <em class="jxr_javadoccomment">     * After succesfull detection, fills Metadata with detected content encoding</em>
+<a name="138" href="#138">138</a> <em class="jxr_javadoccomment">     * and content language ({@link HttpHeaders#CONTENT_LANGUAGE}).</em>
+<a name="139" href="#139">139</a> <em class="jxr_javadoccomment">     * </em>
+<a name="140" href="#140">140</a> <em class="jxr_javadoccomment">     * @return Reader to utf8 encoded reader.</em>
+<a name="141" href="#141">141</a> <em class="jxr_javadoccomment">     */</em>
+<a name="142" href="#142">142</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> Reader getUTF8Reader(InputStream stream, <a href="../../../../org/apache/tika/metadata/Metadata.html">Metadata</a> metadata) <strong class="jxr_keyword">throws</strong> TikaException, IOException{
+<a name="143" href="#143">143</a>         CharsetDetector detector = <strong class="jxr_keyword">new</strong> CharsetDetector();
+<a name="144" href="#144">144</a>     
+<a name="145" href="#145">145</a>         <em class="jxr_comment">// Use the declared character encoding, if available</em>
+<a name="146" href="#146">146</a>         String encoding = metadata.get(Metadata.CONTENT_ENCODING);
+<a name="147" href="#147">147</a>         <strong class="jxr_keyword">if</strong> (encoding != <strong class="jxr_keyword">null</strong>) {
+<a name="148" href="#148">148</a>             detector.setDeclaredEncoding(encoding);
+<a name="149" href="#149">149</a>         }
+<a name="150" href="#150">150</a>     
+<a name="151" href="#151">151</a>         <em class="jxr_comment">// CharsetDetector expects a stream to support marks</em>
+<a name="152" href="#152">152</a>         <strong class="jxr_keyword">if</strong> (!stream.markSupported()) {
+<a name="153" href="#153">153</a>             stream = <strong class="jxr_keyword">new</strong> BufferedInputStream(stream);
+<a name="154" href="#154">154</a>         }
+<a name="155" href="#155">155</a>     
+<a name="156" href="#156">156</a>         detector.setText(stream);
+<a name="157" href="#157">157</a>     
+<a name="158" href="#158">158</a>         CharsetMatch match = detector.detect();
+<a name="159" href="#159">159</a>         <strong class="jxr_keyword">if</strong> (match == <strong class="jxr_keyword">null</strong>) {
+<a name="160" href="#160">160</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../org/apache/tika/exception/TikaException.html">TikaException</a>(<span class="jxr_string">"Unable to detect character encoding"</span>);
+<a name="161" href="#161">161</a>         }
+<a name="162" href="#162">162</a>         
+<a name="163" href="#163">163</a>         metadata.set(Metadata.CONTENT_ENCODING, match.getName());
+<a name="164" href="#164">164</a>         String language = match.getLanguage();
+<a name="165" href="#165">165</a>         <strong class="jxr_keyword">if</strong> (language != <strong class="jxr_keyword">null</strong>) {
+<a name="166" href="#166">166</a>             metadata.set(Metadata.CONTENT_LANGUAGE, match.getLanguage());
+<a name="167" href="#167">167</a>             metadata.set(Metadata.LANGUAGE, match.getLanguage());
+<a name="168" href="#168">168</a>         }
+<a name="169" href="#169">169</a>         
+<a name="170" href="#170">170</a>         <strong class="jxr_keyword">return</strong> match.getReader();
+<a name="171" href="#171">171</a>     }
+<a name="172" href="#172">172</a> 
+<a name="173" href="#173">173</a> }
+</pre>
+<hr/><div id="footer">This page was automatically generated by <a href="http://maven.apache.org/">Maven</a></div></body>
+</html>
+

Added: incubator/tika/site/xref/org/apache/tika/utils/package-frame.html
URL: http://svn.apache.org/viewvc/incubator/tika/site/xref/org/apache/tika/utils/package-frame.html?rev=596146&view=auto
==============================================================================
--- incubator/tika/site/xref/org/apache/tika/utils/package-frame.html (added)
+++ incubator/tika/site/xref/org/apache/tika/utils/package-frame.html Sun Nov 18 14:20:54 2007
@@ -0,0 +1,36 @@
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
+<html xml:lang="en" lang="en">
+	<head>
+		<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
+		<title>Apache Tika 0.1-SNAPSHOT Reference Package org.apache.tika.utils</title>
+		<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="style" />
+	</head>
+	<body>
+
+		<h3>
+        	<a href="package-summary.html" target="classFrame">org.apache.tika.utils</a>
+      	</h3>
+
+      	<h3>Classes</h3>
+
+      	<ul>
+      		          	<li>
+            	<a href="ParseUtils.html" target="classFrame">ParseUtils</a>
+          	</li>
+          	          	<li>
+            	<a href="RegexUtils.html" target="classFrame">RegexUtils</a>
+          	</li>
+          	          	<li>
+            	<a href="RereadableInputStream.html" target="classFrame">RereadableInputStream</a>
+          	</li>
+          	          	<li>
+            	<a href="StringUtil.html" target="classFrame">StringUtil</a>
+          	</li>
+          	          	<li>
+            	<a href="Utils.html" target="classFrame">Utils</a>
+          	</li>
+          	      	</ul>
+
+	</body>
+</html>
\ No newline at end of file

Added: incubator/tika/site/xref/org/apache/tika/utils/package-summary.html
URL: http://svn.apache.org/viewvc/incubator/tika/site/xref/org/apache/tika/utils/package-summary.html?rev=596146&view=auto
==============================================================================
--- incubator/tika/site/xref/org/apache/tika/utils/package-summary.html (added)
+++ incubator/tika/site/xref/org/apache/tika/utils/package-summary.html Sun Nov 18 14:20:54 2007
@@ -0,0 +1,87 @@
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
+<html xml:lang="en" lang="en">
+	<head>
+		<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
+		<title>Apache Tika 0.1-SNAPSHOT Reference Package org.apache.tika.utils</title>
+		<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="style" />
+	</head>
+	<body>
+		      	<div class="overview">
+        	<ul>
+          		<li>
+            		<a href="../../../../overview-summary.html">Overview</a>
+          		</li>
+          		<li class="selected">Package</li>
+        	</ul>
+      	</div>
+      	<div class="framenoframe">
+        	<ul>
+          		<li>
+            		<a href="../../../../index.html" target="_top">FRAMES</a>
+          		</li>
+          		<li>
+            		<a href="package-summary.html" target="_top">NO FRAMES</a>
+          		</li>
+        	</ul>
+      	</div>
+		
+		      	<h2>Package org.apache.tika.utils</h2>
+
+		<table class="summary">
+        	<thead>
+          		<tr>
+            		<th>Class Summary</th>
+          		</tr>
+        	</thead>
+        	<tbody>
+        		            	<tr>
+              		<td>
+                		<a href="ParseUtils.html" target="classFrame">ParseUtils</a>
+              		</td>
+            	</tr>
+				            	<tr>
+              		<td>
+                		<a href="RegexUtils.html" target="classFrame">RegexUtils</a>
+              		</td>
+            	</tr>
+				            	<tr>
+              		<td>
+                		<a href="RereadableInputStream.html" target="classFrame">RereadableInputStream</a>
+              		</td>
+            	</tr>
+				            	<tr>
+              		<td>
+                		<a href="StringUtil.html" target="classFrame">StringUtil</a>
+              		</td>
+            	</tr>
+				            	<tr>
+              		<td>
+                		<a href="Utils.html" target="classFrame">Utils</a>
+              		</td>
+            	</tr>
+				        	</tbody>
+      	</table>
+		
+		      	<div class="overview">
+        	<ul>
+          		<li>
+            		<a href="../../../../overview-summary.html">Overview</a>
+          		</li>
+          		<li class="selected">Package</li>
+        	</ul>
+      	</div>
+      	<div class="framenoframe">
+        	<ul>
+          		<li>
+            		<a href="../../../../index.html" target="_top">FRAMES</a>
+          		</li>
+          		<li>
+            		<a href="package-summary.html" target="_top">NO FRAMES</a>
+          		</li>
+        	</ul>
+      	</div>
+				<hr />
+		Copyright &copy; 2007 The Apache Software Foundation. All Rights Reserved.
+	</body>
+</html>
\ No newline at end of file

Added: incubator/tika/site/xref/overview-frame.html
URL: http://svn.apache.org/viewvc/incubator/tika/site/xref/overview-frame.html?rev=596146&view=auto
==============================================================================
--- incubator/tika/site/xref/overview-frame.html (added)
+++ incubator/tika/site/xref/overview-frame.html Sun Nov 18 14:20:54 2007
@@ -0,0 +1,64 @@
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
+<html xml:lang="en" lang="en">
+	<head>
+		<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
+		<title>Apache Tika 0.1-SNAPSHOT Reference</title>
+		<link rel="stylesheet" type="text/css" href="stylesheet.css" title="style" />
+	</head>
+	<body>
+
+		<h3>
+			<a href="allclasses-frame.html" target="packageFrame">All Classes</a>
+		</h3>
+
+		<h3>Packages</h3>
+
+		<ul>
+						<li>
+				<a href="org/apache/tika/config/package-frame.html" target="packageFrame">org.apache.tika.config</a>
+			</li>
+						<li>
+				<a href="org/apache/tika/exception/package-frame.html" target="packageFrame">org.apache.tika.exception</a>
+			</li>
+						<li>
+				<a href="org/apache/tika/metadata/package-frame.html" target="packageFrame">org.apache.tika.metadata</a>
+			</li>
+						<li>
+				<a href="org/apache/tika/mime/package-frame.html" target="packageFrame">org.apache.tika.mime</a>
+			</li>
+						<li>
+				<a href="org/apache/tika/parser/package-frame.html" target="packageFrame">org.apache.tika.parser</a>
+			</li>
+						<li>
+				<a href="org/apache/tika/parser/html/package-frame.html" target="packageFrame">org.apache.tika.parser.html</a>
+			</li>
+						<li>
+				<a href="org/apache/tika/parser/microsoft/package-frame.html" target="packageFrame">org.apache.tika.parser.microsoft</a>
+			</li>
+						<li>
+				<a href="org/apache/tika/parser/opendocument/package-frame.html" target="packageFrame">org.apache.tika.parser.opendocument</a>
+			</li>
+						<li>
+				<a href="org/apache/tika/parser/pdf/package-frame.html" target="packageFrame">org.apache.tika.parser.pdf</a>
+			</li>
+						<li>
+				<a href="org/apache/tika/parser/rtf/package-frame.html" target="packageFrame">org.apache.tika.parser.rtf</a>
+			</li>
+						<li>
+				<a href="org/apache/tika/parser/txt/package-frame.html" target="packageFrame">org.apache.tika.parser.txt</a>
+			</li>
+						<li>
+				<a href="org/apache/tika/parser/xml/package-frame.html" target="packageFrame">org.apache.tika.parser.xml</a>
+			</li>
+						<li>
+				<a href="org/apache/tika/sax/package-frame.html" target="packageFrame">org.apache.tika.sax</a>
+			</li>
+						<li>
+				<a href="org/apache/tika/utils/package-frame.html" target="packageFrame">org.apache.tika.utils</a>
+			</li>
+					</ul>
+
+	</body>
+</html>
+

Added: incubator/tika/site/xref/overview-summary.html
URL: http://svn.apache.org/viewvc/incubator/tika/site/xref/overview-summary.html?rev=596146&view=auto
==============================================================================
--- incubator/tika/site/xref/overview-summary.html (added)
+++ incubator/tika/site/xref/overview-summary.html Sun Nov 18 14:20:54 2007
@@ -0,0 +1,129 @@
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
+<html xml:lang="en" lang="en">
+	<head>
+		<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
+		<title>Apache Tika 0.1-SNAPSHOT Reference</title>
+		<link rel="stylesheet" type="text/css" href="stylesheet.css" title="style" />
+	</head>
+	<body>
+				<div class="overview">
+			<ul>
+				<li class="selected">Overview</li>
+				<li>Package</li>
+			</ul>
+		</div>
+		<div class="framenoframe">
+			<ul>
+				<li>
+					<a href="index.html" target="_top">FRAMES</a>
+				</li>
+				<li>
+    	        	<a href="overview-summary.html" target="_top">NO FRAMES</a>
+        	  	</li>
+	        </ul>
+      	</div>
+		
+		      	<h2>Apache Tika 0.1-SNAPSHOT Reference</h2>
+
+		<table class="summary">
+        	<thead>
+          		<tr>
+            		<th>Packages</th>
+          		</tr>
+        	</thead>
+        	<tbody>
+    	    	            	<tr>
+              		<td>
+                		<a href="org/apache/tika/config/package-summary.html">org.apache.tika.config</a>
+              		</td>
+            	</tr>
+	          	            	<tr>
+              		<td>
+                		<a href="org/apache/tika/exception/package-summary.html">org.apache.tika.exception</a>
+              		</td>
+            	</tr>
+	          	            	<tr>
+              		<td>
+                		<a href="org/apache/tika/metadata/package-summary.html">org.apache.tika.metadata</a>
+              		</td>
+            	</tr>
+	          	            	<tr>
+              		<td>
+                		<a href="org/apache/tika/mime/package-summary.html">org.apache.tika.mime</a>
+              		</td>
+            	</tr>
+	          	            	<tr>
+              		<td>
+                		<a href="org/apache/tika/parser/package-summary.html">org.apache.tika.parser</a>
+              		</td>
+            	</tr>
+	          	            	<tr>
+              		<td>
+                		<a href="org/apache/tika/parser/html/package-summary.html">org.apache.tika.parser.html</a>
+              		</td>
+            	</tr>
+	          	            	<tr>
+              		<td>
+                		<a href="org/apache/tika/parser/microsoft/package-summary.html">org.apache.tika.parser.microsoft</a>
+              		</td>
+            	</tr>
+	          	            	<tr>
+              		<td>
+                		<a href="org/apache/tika/parser/opendocument/package-summary.html">org.apache.tika.parser.opendocument</a>
+              		</td>
+            	</tr>
+	          	            	<tr>
+              		<td>
+                		<a href="org/apache/tika/parser/pdf/package-summary.html">org.apache.tika.parser.pdf</a>
+              		</td>
+            	</tr>
+	          	            	<tr>
+              		<td>
+                		<a href="org/apache/tika/parser/rtf/package-summary.html">org.apache.tika.parser.rtf</a>
+              		</td>
+            	</tr>
+	          	            	<tr>
+              		<td>
+                		<a href="org/apache/tika/parser/txt/package-summary.html">org.apache.tika.parser.txt</a>
+              		</td>
+            	</tr>
+	          	            	<tr>
+              		<td>
+                		<a href="org/apache/tika/parser/xml/package-summary.html">org.apache.tika.parser.xml</a>
+              		</td>
+            	</tr>
+	          	            	<tr>
+              		<td>
+                		<a href="org/apache/tika/sax/package-summary.html">org.apache.tika.sax</a>
+              		</td>
+            	</tr>
+	          	            	<tr>
+              		<td>
+                		<a href="org/apache/tika/utils/package-summary.html">org.apache.tika.utils</a>
+              		</td>
+            	</tr>
+	          	        	</tbody>
+      	</table>
+		
+				<div class="overview">
+			<ul>
+				<li class="selected">Overview</li>
+				<li>Package</li>
+			</ul>
+		</div>
+		<div class="framenoframe">
+			<ul>
+				<li>
+					<a href="index.html" target="_top">FRAMES</a>
+				</li>
+				<li>
+    	        	<a href="overview-summary.html" target="_top">NO FRAMES</a>
+        	  	</li>
+	        </ul>
+      	</div>
+		
+		<hr />
+		Copyright &copy; 2007 The Apache Software Foundation. All Rights Reserved.
+	</body>
+</html>
\ No newline at end of file

Added: incubator/tika/site/xref/stylesheet.css
URL: http://svn.apache.org/viewvc/incubator/tika/site/xref/stylesheet.css?rev=596146&view=auto
==============================================================================
--- incubator/tika/site/xref/stylesheet.css (added)
+++ incubator/tika/site/xref/stylesheet.css Sun Nov 18 14:20:54 2007
@@ -0,0 +1,116 @@
+/* Javadoc style sheet */
+/* Define colors, fonts and other style attributes here to override the defaults  */
+body {
+    background-color: #fff;
+    font-family: Arial, Helvetica, sans-serif;
+}
+
+a:link {
+    color: #00f;
+}
+a:visited {
+    color: #00a;
+}
+
+a:active, a:hover {
+    color: #f30 !important;
+}
+
+ul, li {
+    list-style-type:none;
+    margin:0;
+    padding:0;
+}
+
+table td {
+    padding: 3px;
+    border: 1px solid #000;
+}
+table {
+    width:100%;
+    border: 1px solid #000;
+    border-collapse: collapse;
+}
+
+div.overview {
+    background-color:#ddd;
+    padding: 4px 4px 4px 0;
+}
+div.overview li, div.framenoframe li {
+    display: inline;
+}
+div.framenoframe {
+    text-align: center;
+    font-size: x-small;
+}
+div.framenoframe li {
+    margin: 0 3px 0 3px;
+}
+div.overview li {
+    margin:3px 3px 0 3px;
+    padding: 4px;
+}
+li.selected {
+    background-color:#888;
+    color: #fff;
+    font-weight: bold;
+}
+
+table.summary {
+    margin-bottom: 20px;
+}
+table.summary td, table.summary th {
+    font-weight: bold;
+    text-align: left;
+    padding: 3px;
+}
+table.summary th {
+    background-color:#036;
+    color: #fff;
+}
+table.summary td {
+    background-color:#eee;
+    border: 1px solid black;
+}
+
+em {
+    color: #A00;
+}
+em.comment {
+    color: #390;
+}
+.string {
+    color: #009;
+}
+div#footer {
+    text-align:center;
+}
+#overview {
+    padding:2px;
+}
+
+hr {
+    height: 1px;
+    color: #000;
+}
+
+/* JXR style sheet */
+.jxr_comment
+{
+    color: #390;
+}
+
+.jxr_javadoccomment
+{
+    color: #A00;
+}
+
+.jxr_string
+{
+    color: #009;
+}
+
+.jxr_keyword
+{
+    color: #000;
+}