You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tika.apache.org by ju...@apache.org on 2008/12/01 00:15:11 UTC

svn commit: r721926 [3/5] - in /lucene/tika/trunk/src: main/java/org/apache/tika/cli/ main/java/org/apache/tika/gui/ main/java/org/apache/tika/mime/ main/java/org/apache/tika/parser/ main/java/org/apache/tika/parser/audio/ main/java/org/apache/tika/par...

Modified: lucene/tika/trunk/src/main/java/org/apache/tika/parser/mp3/Mp3Parser.java
URL: http://svn.apache.org/viewvc/lucene/tika/trunk/src/main/java/org/apache/tika/parser/mp3/Mp3Parser.java?rev=721926&r1=721925&r2=721926&view=diff
==============================================================================
--- lucene/tika/trunk/src/main/java/org/apache/tika/parser/mp3/Mp3Parser.java (original)
+++ lucene/tika/trunk/src/main/java/org/apache/tika/parser/mp3/Mp3Parser.java Sun Nov 30 15:15:09 2008
@@ -1,296 +1,296 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tika.parser.mp3;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-
-import org.apache.tika.exception.TikaException;
-import org.apache.tika.metadata.Metadata;
-import org.apache.tika.parser.Parser;
-import org.apache.tika.sax.XHTMLContentHandler;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-
-/**
- * The <code>Mp3Parser</code> is used to parse ID3 Version 1 Tag information
- * from an MP3 file, if available.
- *
- * @see http://www.id3.org/ID3v1
- */
-public class Mp3Parser implements Parser {
-
-    /**
-     * List of predefined genres.
-     *
-     * @see http://www.id3.org/id3v2-00
-     */
-    private static final String[] GENRES = new String[] {
-        /*  0 */ "Blues",
-        /*  1 */ "Classic Rock",
-        /*  2 */ "Country",
-        /*  3 */ "Dance",
-        /*  4 */ "Disco",
-        /*  5 */ "Funk",
-        /*  6 */ "Grunge",
-        /*  7 */ "Hip-Hop",
-        /*  8 */ "Jazz",
-        /*  9 */ "Metal",
-        /* 10 */ "New Age",
-        /* 11 */ "Oldies",
-        /* 12 */ "Other",
-        /* 13 */ "Pop",
-        /* 14 */ "R&B",
-        /* 15 */ "Rap",
-        /* 16 */ "Reggae",
-        /* 17 */ "Rock",
-        /* 18 */ "Techno",
-        /* 19 */ "Industrial",
-        /* 20 */ "Alternative",
-        /* 21 */ "Ska",
-        /* 22 */ "Death Metal",
-        /* 23 */ "Pranks",
-        /* 24 */ "Soundtrack",
-        /* 25 */ "Euro-Techno",
-        /* 26 */ "Ambient",
-        /* 27 */ "Trip-Hop",
-        /* 28 */ "Vocal",
-        /* 29 */ "Jazz+Funk",
-        /* 30 */ "Fusion",
-        /* 31 */ "Trance",
-        /* 32 */ "Classical",
-        /* 33 */ "Instrumental",
-        /* 34 */ "Acid",
-        /* 35 */ "House",
-        /* 36 */ "Game",
-        /* 37 */ "Sound Clip",
-        /* 38 */ "Gospel",
-        /* 39 */ "Noise",
-        /* 40 */ "AlternRock",
-        /* 41 */ "Bass",
-        /* 42 */ "Soul",
-        /* 43 */ "Punk",
-        /* 44 */ "Space",
-        /* 45 */ "Meditative",
-        /* 46 */ "Instrumental Pop",
-        /* 47 */ "Instrumental Rock",
-        /* 48 */ "Ethnic",
-        /* 49 */ "Gothic",
-        /* 50 */ "Darkwave",
-        /* 51 */ "Techno-Industrial",
-        /* 52 */ "Electronic",
-        /* 53 */ "Pop-Folk",
-        /* 54 */ "Eurodance",
-        /* 55 */ "Dream",
-        /* 56 */ "Southern Rock",
-        /* 57 */ "Comedy",
-        /* 58 */ "Cult",
-        /* 59 */ "Gangsta",
-        /* 60 */ "Top 40",
-        /* 61 */ "Christian Rap",
-        /* 62 */ "Pop/Funk",
-        /* 63 */ "Jungle",
-        /* 64 */ "Native American",
-        /* 65 */ "Cabaret",
-        /* 66 */ "New Wave",
-        /* 67 */ "Psychadelic",
-        /* 68 */ "Rave",
-        /* 69 */ "Showtunes",
-        /* 70 */ "Trailer",
-        /* 71 */ "Lo-Fi",
-        /* 72 */ "Tribal",
-        /* 73 */ "Acid Punk",
-        /* 74 */ "Acid Jazz",
-        /* 75 */ "Polka",
-        /* 76 */ "Retro",
-        /* 77 */ "Musical",
-        /* 78 */ "Rock & Roll",
-        /* 79 */ "Hard Rock",
-        /* 80 */ "Folk",
-        /* 81 */ "Folk-Rock",
-        /* 82 */ "National Folk",
-        /* 83 */ "Swing",
-        /* 84 */ "Fast Fusion",
-        /* 85 */ "Bebob",
-        /* 86 */ "Latin",
-        /* 87 */ "Revival",
-        /* 88 */ "Celtic",
-        /* 89 */ "Bluegrass",
-        /* 90 */ "Avantgarde",
-        /* 91 */ "Gothic Rock",
-        /* 92 */ "Progressive Rock",
-        /* 93 */ "Psychedelic Rock",
-        /* 94 */ "Symphonic Rock",
-        /* 95 */ "Slow Rock",
-        /* 96 */ "Big Band",
-        /* 97 */ "Chorus",
-        /* 98 */ "Easy Listening",
-        /* 99 */ "Acoustic",
-        /* 100 */ "Humour",
-        /* 101 */ "Speech",
-        /* 102 */ "Chanson",
-        /* 103 */ "Opera",
-        /* 104 */ "Chamber Music",
-        /* 105 */ "Sonata",
-        /* 106 */ "Symphony",
-        /* 107 */ "Booty Bass",
-        /* 108 */ "Primus",
-        /* 109 */ "Porn Groove",
-        /* 110 */ "Satire",
-        /* 111 */ "Slow Jam",
-        /* 112 */ "Club",
-        /* 113 */ "Tango",
-        /* 114 */ "Samba",
-        /* 115 */ "Folklore",
-        /* 116 */ "Ballad",
-        /* 117 */ "Power Ballad",
-        /* 118 */ "Rhythmic Soul",
-        /* 119 */ "Freestyle",
-        /* 120 */ "Duet",
-        /* 121 */ "Punk Rock",
-        /* 122 */ "Drum Solo",
-        /* 123 */ "A capella",
-        /* 124 */ "Euro-House",
-        /* 125 */ "Dance Hall",
-        /* sentinel */ ""
-    };
-
-    public void parse(
-            InputStream stream, ContentHandler handler, Metadata metadata)
-            throws IOException, SAXException, TikaException {
-        metadata.set(Metadata.CONTENT_TYPE, "audio/mpeg");
-
-        XHTMLContentHandler xhtml = new XHTMLContentHandler(handler, metadata);
-        xhtml.startDocument();
-
-        byte[] tag = getSuffix(stream, 128);
-        if (tag.length == 128
-                && tag[0] == 'T' && tag[1] == 'A' && tag[2] == 'G') {
-            String title = getString(tag, 3, 33);
-            String artist = getString(tag, 33, 63);
-            String album = getString(tag, 63, 93);
-            String year = getString(tag, 93, 97);
-            String comment = getString(tag, 97, 127);
-            int genre = (int) tag[127] & 0xff; // unsigned byte
-
-            metadata.set(Metadata.TITLE, title);
-            metadata.set(Metadata.AUTHOR, artist);
-
-            xhtml.element("h1", title);
-            xhtml.characters("\n");
-
-            xhtml.element("p", artist);
-            xhtml.characters("\n");
-
-            // ID3v1.1 Track addition
-            // If the last two bytes of the comment field are zero and
-            // non-zero, then the last byte is the track number
-            if (tag[125] == 0 && tag[126] != 0) {
-                int track = (int) tag[126] & 0xff;
-                xhtml.element("p", album + ", track " + track);
-            } else {
-                xhtml.element("p", album);
-            }
-            xhtml.characters("\n");
-
-            xhtml.element("p", year);
-            xhtml.characters("\n");
-
-            xhtml.element("p", comment);
-            xhtml.characters("\n");
-
-            xhtml.element("p", GENRES[Math.min(genre, GENRES.length - 1)]);
-            xhtml.characters("\n");
-        }
-
-        xhtml.endDocument();
-    }
-
-    /**
-     * Returns the identified ISO-8859-1 substring from the given byte buffer.
-     * The return value is the zero-terminated substring retrieved from
-     * between the given start and end positions in the given byte buffer.
-     * Extra whitespace (and control characters) from the beginning and the
-     * end of the substring is removed.
-     *
-     * @param buffer byte buffer
-     * @param start start index of the substring
-     * @param end end index of the substring
-     * @return the identified substring
-     * @throws TikaException if the ISO-8859-1 encoding is not available
-     */
-    private static String getString(byte[] buffer, int start, int end)
-            throws TikaException {
-        // Find the zero byte that marks the end of the string
-        int zero = start;
-        while (zero < end && buffer[zero] != 0) {
-            zero++;
-        }
-
-        // Skip trailing whitespace
-        end = zero;
-        while (start < end && buffer[end - 1] <= ' ') {
-            end--;
-        }
-
-        // Skip leading whitespace
-        while (start < end && buffer[start] <= ' ') {
-            start++;
-        }
-
-        // Return the remaining substring
-        try {
-            return new String(buffer, start, end - start, "ISO-8859-1");
-        } catch (UnsupportedEncodingException e) {
-            throw new TikaException("ISO-8859-1 encoding is not available", e);
-        }
-    }
-
-    /**
-     * Reads and returns the last <code>length</code> bytes from the
-     * given stream.
-     * @param stream input stream
-     * @param length number of bytes from the end to read and return
-     * @return stream the <code>InputStream</code> to read from.
-     * @throws IOException if the stream could not be read from.
-     */
-   private static byte[] getSuffix(InputStream stream, int length)
-           throws IOException {
-       byte[] buffer = new byte[2 * length];
-       int bytesInBuffer = 0;
-
-       int n = stream.read(buffer);
-       while (n != -1) {
-           bytesInBuffer += n;
-           if (bytesInBuffer == buffer.length) {
-               System.arraycopy(buffer, bytesInBuffer - length, buffer, 0, length);
-               bytesInBuffer = length;
-           }
-           n = stream.read(buffer, bytesInBuffer, buffer.length - bytesInBuffer);
-       }
-
-       if (bytesInBuffer < length) {
-           length = bytesInBuffer;
-       }
-
-       byte[] result = new byte[length];
-       System.arraycopy(buffer, bytesInBuffer - length, result, 0, length);
-       return result;
-   }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tika.parser.mp3;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+
+import org.apache.tika.exception.TikaException;
+import org.apache.tika.metadata.Metadata;
+import org.apache.tika.parser.Parser;
+import org.apache.tika.sax.XHTMLContentHandler;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+
+/**
+ * The <code>Mp3Parser</code> is used to parse ID3 Version 1 Tag information
+ * from an MP3 file, if available.
+ *
+ * @see http://www.id3.org/ID3v1
+ */
+public class Mp3Parser implements Parser {
+
+    /**
+     * List of predefined genres.
+     *
+     * @see http://www.id3.org/id3v2-00
+     */
+    private static final String[] GENRES = new String[] {
+        /*  0 */ "Blues",
+        /*  1 */ "Classic Rock",
+        /*  2 */ "Country",
+        /*  3 */ "Dance",
+        /*  4 */ "Disco",
+        /*  5 */ "Funk",
+        /*  6 */ "Grunge",
+        /*  7 */ "Hip-Hop",
+        /*  8 */ "Jazz",
+        /*  9 */ "Metal",
+        /* 10 */ "New Age",
+        /* 11 */ "Oldies",
+        /* 12 */ "Other",
+        /* 13 */ "Pop",
+        /* 14 */ "R&B",
+        /* 15 */ "Rap",
+        /* 16 */ "Reggae",
+        /* 17 */ "Rock",
+        /* 18 */ "Techno",
+        /* 19 */ "Industrial",
+        /* 20 */ "Alternative",
+        /* 21 */ "Ska",
+        /* 22 */ "Death Metal",
+        /* 23 */ "Pranks",
+        /* 24 */ "Soundtrack",
+        /* 25 */ "Euro-Techno",
+        /* 26 */ "Ambient",
+        /* 27 */ "Trip-Hop",
+        /* 28 */ "Vocal",
+        /* 29 */ "Jazz+Funk",
+        /* 30 */ "Fusion",
+        /* 31 */ "Trance",
+        /* 32 */ "Classical",
+        /* 33 */ "Instrumental",
+        /* 34 */ "Acid",
+        /* 35 */ "House",
+        /* 36 */ "Game",
+        /* 37 */ "Sound Clip",
+        /* 38 */ "Gospel",
+        /* 39 */ "Noise",
+        /* 40 */ "AlternRock",
+        /* 41 */ "Bass",
+        /* 42 */ "Soul",
+        /* 43 */ "Punk",
+        /* 44 */ "Space",
+        /* 45 */ "Meditative",
+        /* 46 */ "Instrumental Pop",
+        /* 47 */ "Instrumental Rock",
+        /* 48 */ "Ethnic",
+        /* 49 */ "Gothic",
+        /* 50 */ "Darkwave",
+        /* 51 */ "Techno-Industrial",
+        /* 52 */ "Electronic",
+        /* 53 */ "Pop-Folk",
+        /* 54 */ "Eurodance",
+        /* 55 */ "Dream",
+        /* 56 */ "Southern Rock",
+        /* 57 */ "Comedy",
+        /* 58 */ "Cult",
+        /* 59 */ "Gangsta",
+        /* 60 */ "Top 40",
+        /* 61 */ "Christian Rap",
+        /* 62 */ "Pop/Funk",
+        /* 63 */ "Jungle",
+        /* 64 */ "Native American",
+        /* 65 */ "Cabaret",
+        /* 66 */ "New Wave",
+        /* 67 */ "Psychadelic",
+        /* 68 */ "Rave",
+        /* 69 */ "Showtunes",
+        /* 70 */ "Trailer",
+        /* 71 */ "Lo-Fi",
+        /* 72 */ "Tribal",
+        /* 73 */ "Acid Punk",
+        /* 74 */ "Acid Jazz",
+        /* 75 */ "Polka",
+        /* 76 */ "Retro",
+        /* 77 */ "Musical",
+        /* 78 */ "Rock & Roll",
+        /* 79 */ "Hard Rock",
+        /* 80 */ "Folk",
+        /* 81 */ "Folk-Rock",
+        /* 82 */ "National Folk",
+        /* 83 */ "Swing",
+        /* 84 */ "Fast Fusion",
+        /* 85 */ "Bebob",
+        /* 86 */ "Latin",
+        /* 87 */ "Revival",
+        /* 88 */ "Celtic",
+        /* 89 */ "Bluegrass",
+        /* 90 */ "Avantgarde",
+        /* 91 */ "Gothic Rock",
+        /* 92 */ "Progressive Rock",
+        /* 93 */ "Psychedelic Rock",
+        /* 94 */ "Symphonic Rock",
+        /* 95 */ "Slow Rock",
+        /* 96 */ "Big Band",
+        /* 97 */ "Chorus",
+        /* 98 */ "Easy Listening",
+        /* 99 */ "Acoustic",
+        /* 100 */ "Humour",
+        /* 101 */ "Speech",
+        /* 102 */ "Chanson",
+        /* 103 */ "Opera",
+        /* 104 */ "Chamber Music",
+        /* 105 */ "Sonata",
+        /* 106 */ "Symphony",
+        /* 107 */ "Booty Bass",
+        /* 108 */ "Primus",
+        /* 109 */ "Porn Groove",
+        /* 110 */ "Satire",
+        /* 111 */ "Slow Jam",
+        /* 112 */ "Club",
+        /* 113 */ "Tango",
+        /* 114 */ "Samba",
+        /* 115 */ "Folklore",
+        /* 116 */ "Ballad",
+        /* 117 */ "Power Ballad",
+        /* 118 */ "Rhythmic Soul",
+        /* 119 */ "Freestyle",
+        /* 120 */ "Duet",
+        /* 121 */ "Punk Rock",
+        /* 122 */ "Drum Solo",
+        /* 123 */ "A capella",
+        /* 124 */ "Euro-House",
+        /* 125 */ "Dance Hall",
+        /* sentinel */ ""
+    };
+
+    public void parse(
+            InputStream stream, ContentHandler handler, Metadata metadata)
+            throws IOException, SAXException, TikaException {
+        metadata.set(Metadata.CONTENT_TYPE, "audio/mpeg");
+
+        XHTMLContentHandler xhtml = new XHTMLContentHandler(handler, metadata);
+        xhtml.startDocument();
+
+        byte[] tag = getSuffix(stream, 128);
+        if (tag.length == 128
+                && tag[0] == 'T' && tag[1] == 'A' && tag[2] == 'G') {
+            String title = getString(tag, 3, 33);
+            String artist = getString(tag, 33, 63);
+            String album = getString(tag, 63, 93);
+            String year = getString(tag, 93, 97);
+            String comment = getString(tag, 97, 127);
+            int genre = (int) tag[127] & 0xff; // unsigned byte
+
+            metadata.set(Metadata.TITLE, title);
+            metadata.set(Metadata.AUTHOR, artist);
+
+            xhtml.element("h1", title);
+            xhtml.characters("\n");
+
+            xhtml.element("p", artist);
+            xhtml.characters("\n");
+
+            // ID3v1.1 Track addition
+            // If the last two bytes of the comment field are zero and
+            // non-zero, then the last byte is the track number
+            if (tag[125] == 0 && tag[126] != 0) {
+                int track = (int) tag[126] & 0xff;
+                xhtml.element("p", album + ", track " + track);
+            } else {
+                xhtml.element("p", album);
+            }
+            xhtml.characters("\n");
+
+            xhtml.element("p", year);
+            xhtml.characters("\n");
+
+            xhtml.element("p", comment);
+            xhtml.characters("\n");
+
+            xhtml.element("p", GENRES[Math.min(genre, GENRES.length - 1)]);
+            xhtml.characters("\n");
+        }
+
+        xhtml.endDocument();
+    }
+
+    /**
+     * Returns the identified ISO-8859-1 substring from the given byte buffer.
+     * The return value is the zero-terminated substring retrieved from
+     * between the given start and end positions in the given byte buffer.
+     * Extra whitespace (and control characters) from the beginning and the
+     * end of the substring is removed.
+     *
+     * @param buffer byte buffer
+     * @param start start index of the substring
+     * @param end end index of the substring
+     * @return the identified substring
+     * @throws TikaException if the ISO-8859-1 encoding is not available
+     */
+    private static String getString(byte[] buffer, int start, int end)
+            throws TikaException {
+        // Find the zero byte that marks the end of the string
+        int zero = start;
+        while (zero < end && buffer[zero] != 0) {
+            zero++;
+        }
+
+        // Skip trailing whitespace
+        end = zero;
+        while (start < end && buffer[end - 1] <= ' ') {
+            end--;
+        }
+
+        // Skip leading whitespace
+        while (start < end && buffer[start] <= ' ') {
+            start++;
+        }
+
+        // Return the remaining substring
+        try {
+            return new String(buffer, start, end - start, "ISO-8859-1");
+        } catch (UnsupportedEncodingException e) {
+            throw new TikaException("ISO-8859-1 encoding is not available", e);
+        }
+    }
+
+    /**
+     * Reads and returns the last <code>length</code> bytes from the
+     * given stream.
+     * @param stream input stream
+     * @param length number of bytes from the end to read and return
+     * @return stream the <code>InputStream</code> to read from.
+     * @throws IOException if the stream could not be read from.
+     */
+   private static byte[] getSuffix(InputStream stream, int length)
+           throws IOException {
+       byte[] buffer = new byte[2 * length];
+       int bytesInBuffer = 0;
+
+       int n = stream.read(buffer);
+       while (n != -1) {
+           bytesInBuffer += n;
+           if (bytesInBuffer == buffer.length) {
+               System.arraycopy(buffer, bytesInBuffer - length, buffer, 0, length);
+               bytesInBuffer = length;
+           }
+           n = stream.read(buffer, bytesInBuffer, buffer.length - bytesInBuffer);
+       }
+
+       if (bytesInBuffer < length) {
+           length = bytesInBuffer;
+       }
+
+       byte[] result = new byte[length];
+       System.arraycopy(buffer, bytesInBuffer - length, result, 0, length);
+       return result;
+   }
+
+}

Propchange: lucene/tika/trunk/src/main/java/org/apache/tika/parser/mp3/Mp3Parser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: lucene/tika/trunk/src/main/java/org/apache/tika/parser/opendocument/OpenOfficeContentParser.java
URL: http://svn.apache.org/viewvc/lucene/tika/trunk/src/main/java/org/apache/tika/parser/opendocument/OpenOfficeContentParser.java?rev=721926&r1=721925&r2=721926&view=diff
==============================================================================
--- lucene/tika/trunk/src/main/java/org/apache/tika/parser/opendocument/OpenOfficeContentParser.java (original)
+++ lucene/tika/trunk/src/main/java/org/apache/tika/parser/opendocument/OpenOfficeContentParser.java Sun Nov 30 15:15:09 2008
@@ -1,40 +1,40 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tika.parser.opendocument;
-
-import org.apache.tika.metadata.Metadata;
-import org.apache.tika.parser.xml.XMLParser;
-import org.apache.tika.sax.xpath.MatchingContentHandler;
-import org.apache.tika.sax.xpath.XPathParser;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.helpers.DefaultHandler;
-
-/**
- * Parser for OpenDocument <code>content.xml</code> files.
- */
-public class OpenOfficeContentParser extends XMLParser {
-
-    private static final XPathParser OFFICE_XPATH = new XPathParser(
-            "office", "urn:oasis:names:tc:opendocument:xmlns:office:1.0");
-
-    protected DefaultHandler getDefaultHandler(ContentHandler ch, Metadata md) {
-        return new MatchingContentHandler(
-                super.getDefaultHandler(ch, md),
-                OFFICE_XPATH.parse("//office:body//text()"));
-    }
-
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tika.parser.opendocument;
+
+import org.apache.tika.metadata.Metadata;
+import org.apache.tika.parser.xml.XMLParser;
+import org.apache.tika.sax.xpath.MatchingContentHandler;
+import org.apache.tika.sax.xpath.XPathParser;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ * Parser for OpenDocument <code>content.xml</code> files.
+ */
+public class OpenOfficeContentParser extends XMLParser {
+
+    private static final XPathParser OFFICE_XPATH = new XPathParser(
+            "office", "urn:oasis:names:tc:opendocument:xmlns:office:1.0");
+
+    protected DefaultHandler getDefaultHandler(ContentHandler ch, Metadata md) {
+        return new MatchingContentHandler(
+                super.getDefaultHandler(ch, md),
+                OFFICE_XPATH.parse("//office:body//text()"));
+    }
+
+}

Propchange: lucene/tika/trunk/src/main/java/org/apache/tika/parser/opendocument/OpenOfficeContentParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: lucene/tika/trunk/src/main/java/org/apache/tika/parser/opendocument/OpenOfficeMetaParser.java
URL: http://svn.apache.org/viewvc/lucene/tika/trunk/src/main/java/org/apache/tika/parser/opendocument/OpenOfficeMetaParser.java?rev=721926&r1=721925&r2=721926&view=diff
==============================================================================
--- lucene/tika/trunk/src/main/java/org/apache/tika/parser/opendocument/OpenOfficeMetaParser.java (original)
+++ lucene/tika/trunk/src/main/java/org/apache/tika/parser/opendocument/OpenOfficeMetaParser.java Sun Nov 30 15:15:09 2008
@@ -1,71 +1,71 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tika.parser.opendocument;
-
-import org.apache.tika.metadata.Metadata;
-import org.apache.tika.parser.xml.DcXMLParser;
-import org.apache.tika.parser.xml.MetadataHandler;
-import org.apache.tika.sax.TeeContentHandler;
-import org.apache.tika.sax.xpath.CompositeMatcher;
-import org.apache.tika.sax.xpath.Matcher;
-import org.apache.tika.sax.xpath.MatchingContentHandler;
-import org.apache.tika.sax.xpath.XPathParser;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.helpers.DefaultHandler;
-
-/**
- * Parser for OpenDocument <code>meta.xml</code> files.
- */
-public class OpenOfficeMetaParser extends DcXMLParser {
-
-    private static final XPathParser META_XPATH = new XPathParser(
-            "meta", "urn:oasis:names:tc:opendocument:xmlns:meta:1.0");
-
-    private static DefaultHandler getMeta(
-            ContentHandler ch, Metadata md, String name, String element) {
-        Matcher matcher = new CompositeMatcher(
-                META_XPATH.parse("//meta:" + element),
-                META_XPATH.parse("//meta:" + element + "//text()"));
-        ContentHandler branch =
-            new MatchingContentHandler(new MetadataHandler(md, name), matcher);
-        return new TeeContentHandler(ch, branch);
-    }
-
-    private static DefaultHandler getStatistic(
-            ContentHandler ch, Metadata md, String name, String attribute) {
-        Matcher matcher =
-            META_XPATH.parse("//meta:document-statistic/@meta:" + attribute);
-        ContentHandler branch =
-            new MatchingContentHandler(new MetadataHandler(md, name), matcher);
-        return new TeeContentHandler(ch, branch);
-    }
-
-    protected DefaultHandler getDefaultHandler(ContentHandler ch, Metadata md) {
-        DefaultHandler dh = super.getDefaultHandler(ch, md);
-        dh = getMeta(dh, md, Metadata.KEYWORDS, "keyword");
-        dh = getMeta(dh, md, "generator", "generator");
-        dh = getStatistic(dh, md, "nbTab", "table-count");
-        dh = getStatistic(dh, md, "nbObject", "object-count");
-        dh = getStatistic(dh, md, "nbImg", "image-count");
-        dh = getStatistic(dh, md, "nbPage", "page-count");
-        dh = getStatistic(dh, md, "nbPara", "paragraph-count");
-        dh = getStatistic(dh, md, "nbWord", "word-count");
-        dh = getStatistic(dh, md, "nbCharacter", "character-count");
-        return dh;
-    }
-
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tika.parser.opendocument;
+
+import org.apache.tika.metadata.Metadata;
+import org.apache.tika.parser.xml.DcXMLParser;
+import org.apache.tika.parser.xml.MetadataHandler;
+import org.apache.tika.sax.TeeContentHandler;
+import org.apache.tika.sax.xpath.CompositeMatcher;
+import org.apache.tika.sax.xpath.Matcher;
+import org.apache.tika.sax.xpath.MatchingContentHandler;
+import org.apache.tika.sax.xpath.XPathParser;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ * Parser for OpenDocument <code>meta.xml</code> files.
+ */
+public class OpenOfficeMetaParser extends DcXMLParser {
+
+    private static final XPathParser META_XPATH = new XPathParser(
+            "meta", "urn:oasis:names:tc:opendocument:xmlns:meta:1.0");
+
+    private static DefaultHandler getMeta(
+            ContentHandler ch, Metadata md, String name, String element) {
+        Matcher matcher = new CompositeMatcher(
+                META_XPATH.parse("//meta:" + element),
+                META_XPATH.parse("//meta:" + element + "//text()"));
+        ContentHandler branch =
+            new MatchingContentHandler(new MetadataHandler(md, name), matcher);
+        return new TeeContentHandler(ch, branch);
+    }
+
+    private static DefaultHandler getStatistic(
+            ContentHandler ch, Metadata md, String name, String attribute) {
+        Matcher matcher =
+            META_XPATH.parse("//meta:document-statistic/@meta:" + attribute);
+        ContentHandler branch =
+            new MatchingContentHandler(new MetadataHandler(md, name), matcher);
+        return new TeeContentHandler(ch, branch);
+    }
+
+    protected DefaultHandler getDefaultHandler(ContentHandler ch, Metadata md) {
+        DefaultHandler dh = super.getDefaultHandler(ch, md);
+        dh = getMeta(dh, md, Metadata.KEYWORDS, "keyword");
+        dh = getMeta(dh, md, "generator", "generator");
+        dh = getStatistic(dh, md, "nbTab", "table-count");
+        dh = getStatistic(dh, md, "nbObject", "object-count");
+        dh = getStatistic(dh, md, "nbImg", "image-count");
+        dh = getStatistic(dh, md, "nbPage", "page-count");
+        dh = getStatistic(dh, md, "nbPara", "paragraph-count");
+        dh = getStatistic(dh, md, "nbWord", "word-count");
+        dh = getStatistic(dh, md, "nbCharacter", "character-count");
+        return dh;
+    }
+
+}

Propchange: lucene/tika/trunk/src/main/java/org/apache/tika/parser/opendocument/OpenOfficeMetaParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: lucene/tika/trunk/src/main/java/org/apache/tika/parser/pkg/Bzip2Parser.java
URL: http://svn.apache.org/viewvc/lucene/tika/trunk/src/main/java/org/apache/tika/parser/pkg/Bzip2Parser.java?rev=721926&r1=721925&r2=721926&view=diff
==============================================================================
--- lucene/tika/trunk/src/main/java/org/apache/tika/parser/pkg/Bzip2Parser.java (original)
+++ lucene/tika/trunk/src/main/java/org/apache/tika/parser/pkg/Bzip2Parser.java Sun Nov 30 15:15:09 2008
@@ -1,78 +1,78 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tika.parser.pkg;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.apache.commons.io.input.CloseShieldInputStream;
-import org.apache.tika.exception.TikaException;
-import org.apache.tika.metadata.Metadata;
-import org.apache.tika.parser.pkg.bzip2.CBZip2InputStream;
-import org.apache.tika.sax.XHTMLContentHandler;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-
-/**
- * Gzip parser.
- */
-public class Bzip2Parser extends PackageParser {
-
-    /**
-     * Parses the given stream as a gzip file.
-     */
-    public void parse(
-            InputStream stream, ContentHandler handler, Metadata metadata)
-            throws IOException, SAXException, TikaException {
-        // The CBZip2InputStream class does not want to see the magic BZ header
-        if (stream.read() != 'B' || stream.read() != 'Z') {
-            throw new TikaException("Invalid BZip2 magic header");
-        }
-
-        metadata.set(Metadata.CONTENT_TYPE, "application/x-bzip");
-
-        XHTMLContentHandler xhtml = new XHTMLContentHandler(handler, metadata);
-        xhtml.startDocument();
-
-        // At the end we want to close the bzip2 stream to release any associated
-        // resources, but the underlying document stream should not be closed
-        InputStream gzip =
-            new CBZip2InputStream(new CloseShieldInputStream(stream));
-        try {
-            Metadata entrydata = new Metadata();
-            String name = metadata.get(Metadata.RESOURCE_NAME_KEY);
-            if (name != null) {
-                if (name.endsWith(".tbz")) {
-                    name = name.substring(0, name.length() - 4) + ".tar";
-                } else if (name.endsWith(".tbz2")) {
-                    name = name.substring(0, name.length() - 5) + ".tar";
-                } else if (name.endsWith(".bz")) {
-                    name = name.substring(0, name.length() - 3);
-                } else if (name.endsWith(".bz2")) {
-                    name = name.substring(0, name.length() - 4);
-                }
-                entrydata.set(Metadata.RESOURCE_NAME_KEY, name);
-            }
-            parseEntry(gzip, xhtml, entrydata);
-        } finally {
-            gzip.close();
-        }
-
-        xhtml.endDocument();
-    }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tika.parser.pkg;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.commons.io.input.CloseShieldInputStream;
+import org.apache.tika.exception.TikaException;
+import org.apache.tika.metadata.Metadata;
+import org.apache.tika.parser.pkg.bzip2.CBZip2InputStream;
+import org.apache.tika.sax.XHTMLContentHandler;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+
+/**
+ * Gzip parser.
+ */
+public class Bzip2Parser extends PackageParser {
+
+    /**
+     * Parses the given stream as a gzip file.
+     */
+    public void parse(
+            InputStream stream, ContentHandler handler, Metadata metadata)
+            throws IOException, SAXException, TikaException {
+        // The CBZip2InputStream class does not want to see the magic BZ header
+        if (stream.read() != 'B' || stream.read() != 'Z') {
+            throw new TikaException("Invalid BZip2 magic header");
+        }
+
+        metadata.set(Metadata.CONTENT_TYPE, "application/x-bzip");
+
+        XHTMLContentHandler xhtml = new XHTMLContentHandler(handler, metadata);
+        xhtml.startDocument();
+
+        // At the end we want to close the bzip2 stream to release any associated
+        // resources, but the underlying document stream should not be closed
+        InputStream gzip =
+            new CBZip2InputStream(new CloseShieldInputStream(stream));
+        try {
+            Metadata entrydata = new Metadata();
+            String name = metadata.get(Metadata.RESOURCE_NAME_KEY);
+            if (name != null) {
+                if (name.endsWith(".tbz")) {
+                    name = name.substring(0, name.length() - 4) + ".tar";
+                } else if (name.endsWith(".tbz2")) {
+                    name = name.substring(0, name.length() - 5) + ".tar";
+                } else if (name.endsWith(".bz")) {
+                    name = name.substring(0, name.length() - 3);
+                } else if (name.endsWith(".bz2")) {
+                    name = name.substring(0, name.length() - 4);
+                }
+                entrydata.set(Metadata.RESOURCE_NAME_KEY, name);
+            }
+            parseEntry(gzip, xhtml, entrydata);
+        } finally {
+            gzip.close();
+        }
+
+        xhtml.endDocument();
+    }
+
+}

Propchange: lucene/tika/trunk/src/main/java/org/apache/tika/parser/pkg/Bzip2Parser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: lucene/tika/trunk/src/main/java/org/apache/tika/parser/pkg/GzipParser.java
URL: http://svn.apache.org/viewvc/lucene/tika/trunk/src/main/java/org/apache/tika/parser/pkg/GzipParser.java?rev=721926&r1=721925&r2=721926&view=diff
==============================================================================
--- lucene/tika/trunk/src/main/java/org/apache/tika/parser/pkg/GzipParser.java (original)
+++ lucene/tika/trunk/src/main/java/org/apache/tika/parser/pkg/GzipParser.java Sun Nov 30 15:15:09 2008
@@ -1,69 +1,69 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tika.parser.pkg;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.zip.GZIPInputStream;
-
-import org.apache.commons.io.input.CloseShieldInputStream;
-import org.apache.tika.exception.TikaException;
-import org.apache.tika.metadata.Metadata;
-import org.apache.tika.sax.XHTMLContentHandler;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-
-/**
- * Gzip parser.
- */
-public class GzipParser extends PackageParser {
-
-    /**
-     * Parses the given stream as a gzip file.
-     */
-    public void parse(
-            InputStream stream, ContentHandler handler, Metadata metadata)
-            throws IOException, SAXException, TikaException {
-        metadata.set(Metadata.CONTENT_TYPE, "application/x-gzip");
-
-        XHTMLContentHandler xhtml = new XHTMLContentHandler(handler, metadata);
-        xhtml.startDocument();
-
-        // At the end we want to close the gzip stream to release any associated
-        // resources, but the underlying document stream should not be closed
-        InputStream gzip =
-            new GZIPInputStream(new CloseShieldInputStream(stream));
-        try {
-            Metadata entrydata = new Metadata();
-            String name = metadata.get(Metadata.RESOURCE_NAME_KEY);
-            if (name != null) {
-                if (name.endsWith(".tgz")) {
-                    name = name.substring(0, name.length() - 4) + ".tar";
-                } else if (name.endsWith(".gz") || name.endsWith("-gz")) {
-                    name = name.substring(0, name.length() - 3);
-                }
-                entrydata.set(Metadata.RESOURCE_NAME_KEY, name);
-            }
-            parseEntry(gzip, xhtml, entrydata);
-        } finally {
-            gzip.close();
-        }
-
-        xhtml.endDocument();
-    }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tika.parser.pkg;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.zip.GZIPInputStream;
+
+import org.apache.commons.io.input.CloseShieldInputStream;
+import org.apache.tika.exception.TikaException;
+import org.apache.tika.metadata.Metadata;
+import org.apache.tika.sax.XHTMLContentHandler;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+
+/**
+ * Gzip parser.
+ */
+public class GzipParser extends PackageParser {
+
+    /**
+     * Parses the given stream as a gzip file.
+     */
+    public void parse(
+            InputStream stream, ContentHandler handler, Metadata metadata)
+            throws IOException, SAXException, TikaException {
+        metadata.set(Metadata.CONTENT_TYPE, "application/x-gzip");
+
+        XHTMLContentHandler xhtml = new XHTMLContentHandler(handler, metadata);
+        xhtml.startDocument();
+
+        // At the end we want to close the gzip stream to release any associated
+        // resources, but the underlying document stream should not be closed
+        InputStream gzip =
+            new GZIPInputStream(new CloseShieldInputStream(stream));
+        try {
+            Metadata entrydata = new Metadata();
+            String name = metadata.get(Metadata.RESOURCE_NAME_KEY);
+            if (name != null) {
+                if (name.endsWith(".tgz")) {
+                    name = name.substring(0, name.length() - 4) + ".tar";
+                } else if (name.endsWith(".gz") || name.endsWith("-gz")) {
+                    name = name.substring(0, name.length() - 3);
+                }
+                entrydata.set(Metadata.RESOURCE_NAME_KEY, name);
+            }
+            parseEntry(gzip, xhtml, entrydata);
+        } finally {
+            gzip.close();
+        }
+
+        xhtml.endDocument();
+    }
+
+}

Propchange: lucene/tika/trunk/src/main/java/org/apache/tika/parser/pkg/GzipParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: lucene/tika/trunk/src/main/java/org/apache/tika/parser/pkg/PackageParser.java
URL: http://svn.apache.org/viewvc/lucene/tika/trunk/src/main/java/org/apache/tika/parser/pkg/PackageParser.java?rev=721926&r1=721925&r2=721926&view=diff
==============================================================================
--- lucene/tika/trunk/src/main/java/org/apache/tika/parser/pkg/PackageParser.java (original)
+++ lucene/tika/trunk/src/main/java/org/apache/tika/parser/pkg/PackageParser.java Sun Nov 30 15:15:09 2008
@@ -1,105 +1,105 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tika.parser.pkg;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.apache.commons.io.input.CloseShieldInputStream;
-import org.apache.tika.exception.TikaException;
-import org.apache.tika.metadata.Metadata;
-import org.apache.tika.parser.AutoDetectParser;
-import org.apache.tika.parser.Parser;
-import org.apache.tika.sax.BodyContentHandler;
-import org.apache.tika.sax.XHTMLContentHandler;
-import org.xml.sax.SAXException;
-
-/**
- * Abstract base class for parsers that deal with package formats.
- * Subclasses can call the
- * {@link #parseEntry(InputStream, XHTMLContentHandler, Metadata)}
- * method to parse the given package entry using the configured
- * entry parser. The entries will be written to the XHTML event stream
- * as &lt;div class="package-entry"&gt; elements that contain the
- * (optional) entry name as a &lt;h1&gt; element and the full
- * structured body content of the parsed entry.
- */
-public abstract class PackageParser implements Parser {
-
-    /**
-     * The parser instance used to parse package entries.
-     */
-    private Parser parser;
-
-    /**
-     * Returns the parser instance used to parse package entries.
-     *
-     * @return entry parser
-     */
-    public Parser getParser() {
-        Parser parser = this.parser;
-        if (parser == null) {
-            parser = new AutoDetectParser();
-        }
-        return parser;
-    }
-
-    /**
-     * Sets the parser instance used to parse package entries.
-     *
-     * @param parser entry parser
-     */
-    public void setParser(Parser parser) {
-        this.parser = parser;
-    }
-
-    /**
-     * Parses the given entry entry using the underlying parser instance.
-     * It is not an error if the entry can not be parsed, in that case
-     * just the entry name (if given) is emitted.
-     *
-     * @param stream entry stream
-     * @param xhtml XHTML event handler
-     * @param metadata entry metadata
-     * @throws IOException if an IO error occurs
-     * @throws SAXException if a SAX error occurs
-     */
-    protected void parseEntry(
-            InputStream stream, XHTMLContentHandler xhtml, Metadata metadata)
-            throws IOException, SAXException {
-        xhtml.startElement("div", "class", "package-entry");
-
-        String name = metadata.get(Metadata.RESOURCE_NAME_KEY);
-        if (name != null) {
-            xhtml.element("h1", name);
-            xhtml.characters("\n");
-        }
-
-        try {
-            getParser().parse(
-                    new CloseShieldInputStream(stream),
-                    new BodyContentHandler(xhtml),
-                    metadata);
-            xhtml.characters("\n");
-        } catch (TikaException e) {
-            // Could not parse the entry, just skip the content
-        }
-
-        xhtml.endElement("div");
-    }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tika.parser.pkg;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.commons.io.input.CloseShieldInputStream;
+import org.apache.tika.exception.TikaException;
+import org.apache.tika.metadata.Metadata;
+import org.apache.tika.parser.AutoDetectParser;
+import org.apache.tika.parser.Parser;
+import org.apache.tika.sax.BodyContentHandler;
+import org.apache.tika.sax.XHTMLContentHandler;
+import org.xml.sax.SAXException;
+
+/**
+ * Abstract base class for parsers that deal with package formats.
+ * Subclasses can call the
+ * {@link #parseEntry(InputStream, XHTMLContentHandler, Metadata)}
+ * method to parse the given package entry using the configured
+ * entry parser. The entries will be written to the XHTML event stream
+ * as &lt;div class="package-entry"&gt; elements that contain the
+ * (optional) entry name as a &lt;h1&gt; element and the full
+ * structured body content of the parsed entry.
+ */
+public abstract class PackageParser implements Parser {
+
+    /**
+     * The parser instance used to parse package entries.
+     */
+    private Parser parser;
+
+    /**
+     * Returns the parser instance used to parse package entries.
+     *
+     * @return entry parser
+     */
+    public Parser getParser() {
+        Parser parser = this.parser;
+        if (parser == null) {
+            parser = new AutoDetectParser();
+        }
+        return parser;
+    }
+
+    /**
+     * Sets the parser instance used to parse package entries.
+     *
+     * @param parser entry parser
+     */
+    public void setParser(Parser parser) {
+        this.parser = parser;
+    }
+
+    /**
+     * Parses the given entry entry using the underlying parser instance.
+     * It is not an error if the entry can not be parsed, in that case
+     * just the entry name (if given) is emitted.
+     *
+     * @param stream entry stream
+     * @param xhtml XHTML event handler
+     * @param metadata entry metadata
+     * @throws IOException if an IO error occurs
+     * @throws SAXException if a SAX error occurs
+     */
+    protected void parseEntry(
+            InputStream stream, XHTMLContentHandler xhtml, Metadata metadata)
+            throws IOException, SAXException {
+        xhtml.startElement("div", "class", "package-entry");
+
+        String name = metadata.get(Metadata.RESOURCE_NAME_KEY);
+        if (name != null) {
+            xhtml.element("h1", name);
+            xhtml.characters("\n");
+        }
+
+        try {
+            getParser().parse(
+                    new CloseShieldInputStream(stream),
+                    new BodyContentHandler(xhtml),
+                    metadata);
+            xhtml.characters("\n");
+        } catch (TikaException e) {
+            // Could not parse the entry, just skip the content
+        }
+
+        xhtml.endElement("div");
+    }
+
+}

Propchange: lucene/tika/trunk/src/main/java/org/apache/tika/parser/pkg/PackageParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: lucene/tika/trunk/src/main/java/org/apache/tika/parser/pkg/TarParser.java
URL: http://svn.apache.org/viewvc/lucene/tika/trunk/src/main/java/org/apache/tika/parser/pkg/TarParser.java?rev=721926&r1=721925&r2=721926&view=diff
==============================================================================
--- lucene/tika/trunk/src/main/java/org/apache/tika/parser/pkg/TarParser.java (original)
+++ lucene/tika/trunk/src/main/java/org/apache/tika/parser/pkg/TarParser.java Sun Nov 30 15:15:09 2008
@@ -1,68 +1,68 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tika.parser.pkg;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.apache.commons.io.input.CloseShieldInputStream;
-import org.apache.tika.exception.TikaException;
-import org.apache.tika.metadata.Metadata;
-import org.apache.tika.parser.pkg.tar.TarEntry;
-import org.apache.tika.parser.pkg.tar.TarInputStream;
-import org.apache.tika.sax.XHTMLContentHandler;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-
-/**
- * Tar parser.
- */
-public class TarParser extends PackageParser {
-
-    /**
-     * Parses the given stream as a tar file.
-     */
-    public void parse(
-            InputStream stream, ContentHandler handler, Metadata metadata)
-            throws IOException, TikaException, SAXException {
-        metadata.set(Metadata.CONTENT_TYPE, "application/x-tar");
-
-        XHTMLContentHandler xhtml = new XHTMLContentHandler(handler, metadata);
-        xhtml.startDocument();
-
-        // At the end we want to close the tar stream to release any associated
-        // resources, but the underlying document stream should not be closed
-        TarInputStream tar =
-            new TarInputStream(new CloseShieldInputStream(stream));
-        try {
-            TarEntry entry = tar.getNextEntry();
-            while (entry != null) {
-                if (!entry.isDirectory()) {
-                    Metadata entrydata = new Metadata();
-                    entrydata.set(Metadata.RESOURCE_NAME_KEY, entry.getName());
-                    parseEntry(tar, xhtml, entrydata);
-                }
-                entry = tar.getNextEntry();
-            }
-        } finally {
-            tar.close();
-        }
-
-        xhtml.endDocument();
-    }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tika.parser.pkg;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.commons.io.input.CloseShieldInputStream;
+import org.apache.tika.exception.TikaException;
+import org.apache.tika.metadata.Metadata;
+import org.apache.tika.parser.pkg.tar.TarEntry;
+import org.apache.tika.parser.pkg.tar.TarInputStream;
+import org.apache.tika.sax.XHTMLContentHandler;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+
+/**
+ * Tar parser.
+ */
+public class TarParser extends PackageParser {
+
+    /**
+     * Parses the given stream as a tar file.
+     */
+    public void parse(
+            InputStream stream, ContentHandler handler, Metadata metadata)
+            throws IOException, TikaException, SAXException {
+        metadata.set(Metadata.CONTENT_TYPE, "application/x-tar");
+
+        XHTMLContentHandler xhtml = new XHTMLContentHandler(handler, metadata);
+        xhtml.startDocument();
+
+        // At the end we want to close the tar stream to release any associated
+        // resources, but the underlying document stream should not be closed
+        TarInputStream tar =
+            new TarInputStream(new CloseShieldInputStream(stream));
+        try {
+            TarEntry entry = tar.getNextEntry();
+            while (entry != null) {
+                if (!entry.isDirectory()) {
+                    Metadata entrydata = new Metadata();
+                    entrydata.set(Metadata.RESOURCE_NAME_KEY, entry.getName());
+                    parseEntry(tar, xhtml, entrydata);
+                }
+                entry = tar.getNextEntry();
+            }
+        } finally {
+            tar.close();
+        }
+
+        xhtml.endDocument();
+    }
+
+}

Propchange: lucene/tika/trunk/src/main/java/org/apache/tika/parser/pkg/TarParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: lucene/tika/trunk/src/main/java/org/apache/tika/parser/xml/MetadataHandler.java
URL: http://svn.apache.org/viewvc/lucene/tika/trunk/src/main/java/org/apache/tika/parser/xml/MetadataHandler.java?rev=721926&r1=721925&r2=721926&view=diff
==============================================================================
--- lucene/tika/trunk/src/main/java/org/apache/tika/parser/xml/MetadataHandler.java (original)
+++ lucene/tika/trunk/src/main/java/org/apache/tika/parser/xml/MetadataHandler.java Sun Nov 30 15:15:09 2008
@@ -1,63 +1,63 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tika.parser.xml;
-
-import org.apache.tika.metadata.Metadata;
-import org.xml.sax.Attributes;
-import org.xml.sax.helpers.DefaultHandler;
-
-public class MetadataHandler extends DefaultHandler {
-
-    private final Metadata metadata;
-
-    private final String name;
-
-    private final StringBuilder buffer = new StringBuilder();
-
-    public MetadataHandler(Metadata metadata, String name) {
-        this.metadata = metadata;
-        this.name = name;
-    }
-
-    public void addMetadata(String value) {
-        if (value.length() > 0) {
-            String previous = metadata.get(name);
-            if (previous != null && previous.length() > 0) {
-                value = previous + ", " + value;
-            }
-            metadata.set(name, value);
-        }
-    }
-
-    public void endElement(String uri, String localName, String name) {
-        addMetadata(buffer.toString());
-        buffer.setLength(0);
-    }
-
-    public void startElement(
-            String uri, String localName, String name, Attributes attributes) {
-        for (int i = 0; i < attributes.getLength(); i++) {
-            addMetadata(attributes.getValue(i));
-        }
-    }
-
-    
-    public void characters(char[] ch, int start, int length) {
-        buffer.append(ch, start, length);
-    }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tika.parser.xml;
+
+import org.apache.tika.metadata.Metadata;
+import org.xml.sax.Attributes;
+import org.xml.sax.helpers.DefaultHandler;
+
+public class MetadataHandler extends DefaultHandler {
+
+    private final Metadata metadata;
+
+    private final String name;
+
+    private final StringBuilder buffer = new StringBuilder();
+
+    public MetadataHandler(Metadata metadata, String name) {
+        this.metadata = metadata;
+        this.name = name;
+    }
+
+    public void addMetadata(String value) {
+        if (value.length() > 0) {
+            String previous = metadata.get(name);
+            if (previous != null && previous.length() > 0) {
+                value = previous + ", " + value;
+            }
+            metadata.set(name, value);
+        }
+    }
+
+    public void endElement(String uri, String localName, String name) {
+        addMetadata(buffer.toString());
+        buffer.setLength(0);
+    }
+
+    public void startElement(
+            String uri, String localName, String name, Attributes attributes) {
+        for (int i = 0; i < attributes.getLength(); i++) {
+            addMetadata(attributes.getValue(i));
+        }
+    }
+
+    
+    public void characters(char[] ch, int start, int length) {
+        buffer.append(ch, start, length);
+    }
+
+}

Propchange: lucene/tika/trunk/src/main/java/org/apache/tika/parser/xml/MetadataHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: lucene/tika/trunk/src/main/java/org/apache/tika/parser/xml/XMLParser.java
URL: http://svn.apache.org/viewvc/lucene/tika/trunk/src/main/java/org/apache/tika/parser/xml/XMLParser.java?rev=721926&r1=721925&r2=721926&view=diff
==============================================================================
--- lucene/tika/trunk/src/main/java/org/apache/tika/parser/xml/XMLParser.java (original)
+++ lucene/tika/trunk/src/main/java/org/apache/tika/parser/xml/XMLParser.java Sun Nov 30 15:15:09 2008
@@ -1,73 +1,73 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tika.parser.xml;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-
-import org.apache.commons.io.input.CloseShieldInputStream;
-import org.apache.tika.exception.TikaException;
-import org.apache.tika.metadata.Metadata;
-import org.apache.tika.parser.Parser;
-import org.apache.tika.sax.TextContentHandler;
-import org.apache.tika.sax.XHTMLContentHandler;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.DefaultHandler;
-
-/**
- * XML parser
- */
-public class XMLParser implements Parser {
-
-    public void parse(
-            InputStream stream, ContentHandler handler, Metadata metadata)
-            throws IOException, SAXException, TikaException {
-        if (metadata.get(Metadata.CONTENT_TYPE) == null) {
-            metadata.set(Metadata.CONTENT_TYPE, "application/xml");
-        }
-
-        final XHTMLContentHandler xhtml =
-            new XHTMLContentHandler(handler, metadata);
-        xhtml.startDocument();
-        xhtml.startElement("p");
-
-        try {
-            SAXParserFactory factory = SAXParserFactory.newInstance();
-            factory.setNamespaceAware(true);
-            SAXParser parser = factory.newSAXParser();
-            parser.parse(
-                    new CloseShieldInputStream(stream),
-                    getDefaultHandler(handler, metadata));
-        } catch (ParserConfigurationException e) {
-            throw new TikaException("XML parser configuration error", e);
-        }
-
-        xhtml.endElement("p");
-        xhtml.endDocument();
-    }
-
-    protected DefaultHandler getDefaultHandler(
-            ContentHandler handler, Metadata metadata) {
-        return new TextContentHandler(handler);
-    }
-
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tika.parser.xml;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.apache.commons.io.input.CloseShieldInputStream;
+import org.apache.tika.exception.TikaException;
+import org.apache.tika.metadata.Metadata;
+import org.apache.tika.parser.Parser;
+import org.apache.tika.sax.TextContentHandler;
+import org.apache.tika.sax.XHTMLContentHandler;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ * XML parser
+ */
+public class XMLParser implements Parser {
+
+    public void parse(
+            InputStream stream, ContentHandler handler, Metadata metadata)
+            throws IOException, SAXException, TikaException {
+        if (metadata.get(Metadata.CONTENT_TYPE) == null) {
+            metadata.set(Metadata.CONTENT_TYPE, "application/xml");
+        }
+
+        final XHTMLContentHandler xhtml =
+            new XHTMLContentHandler(handler, metadata);
+        xhtml.startDocument();
+        xhtml.startElement("p");
+
+        try {
+            SAXParserFactory factory = SAXParserFactory.newInstance();
+            factory.setNamespaceAware(true);
+            SAXParser parser = factory.newSAXParser();
+            parser.parse(
+                    new CloseShieldInputStream(stream),
+                    getDefaultHandler(handler, metadata));
+        } catch (ParserConfigurationException e) {
+            throw new TikaException("XML parser configuration error", e);
+        }
+
+        xhtml.endElement("p");
+        xhtml.endDocument();
+    }
+
+    protected DefaultHandler getDefaultHandler(
+            ContentHandler handler, Metadata metadata) {
+        return new TextContentHandler(handler);
+    }
+
+}

Propchange: lucene/tika/trunk/src/main/java/org/apache/tika/parser/xml/XMLParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: lucene/tika/trunk/src/main/java/org/apache/tika/sax/BodyContentHandler.java
URL: http://svn.apache.org/viewvc/lucene/tika/trunk/src/main/java/org/apache/tika/sax/BodyContentHandler.java?rev=721926&r1=721925&r2=721926&view=diff
==============================================================================
--- lucene/tika/trunk/src/main/java/org/apache/tika/sax/BodyContentHandler.java (original)
+++ lucene/tika/trunk/src/main/java/org/apache/tika/sax/BodyContentHandler.java Sun Nov 30 15:15:09 2008
@@ -1,85 +1,85 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tika.sax;
-
-import java.io.OutputStream;
-import java.io.Writer;
-
-import org.apache.tika.sax.xpath.Matcher;
-import org.apache.tika.sax.xpath.MatchingContentHandler;
-import org.apache.tika.sax.xpath.XPathParser;
-import org.xml.sax.ContentHandler;
-
-/**
- * Content handler decorator that only passes everything inside
- * the XHTML &lt;body/&gt; tag to the underlying handler. Note that
- * the &lt;body/&gt; tag itself is <em>not</em> passed on.
- */
-public class BodyContentHandler extends ContentHandlerDecorator {
-
-    /**
-     * XHTML XPath parser.
-     */
-    private static final XPathParser PARSER =
-        new XPathParser("xhtml", XHTMLContentHandler.XHTML);
-
-    /**
-     * The XPath matcher used to select the XHTML body contents.
-     */
-    private static final Matcher MATCHER =
-        PARSER.parse("/xhtml:html/xhtml:body/descendant:node()");
-
-    /**
-     * Creates a content handler that passes all XHTML body events to the
-     * given underlying content handler.
-     *
-     * @param handler content handler
-     */
-    public BodyContentHandler(ContentHandler handler) {
-        super(new MatchingContentHandler(handler, MATCHER));
-    }
-
-    /**
-     * Creates a content handler that writes XHTML body character events to
-     * the given writer.
-     *
-     * @param writer writer
-     */
-    public BodyContentHandler(Writer writer) {
-        this(new XHTMLToTextContentHandler(new WriteOutContentHandler(writer)));
-    }
-
-    /**
-     * Creates a content handler that writes XHTML body character events to
-     * the given output stream using the default encoding.
-     *
-     * @param stream output stream
-     */
-    public BodyContentHandler(OutputStream stream) {
-        this(new XHTMLToTextContentHandler(new WriteOutContentHandler(stream)));
-    }
-
-    /**
-     * Creates a content handler that writes XHTML body character events to
-     * an internal string buffer. The contents of the buffer can be retrieved
-     * using the {@link #toString()} method.
-     */
-    public BodyContentHandler() {
-        this(new XHTMLToTextContentHandler(new WriteOutContentHandler()));
-    }
-
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tika.sax;
+
+import java.io.OutputStream;
+import java.io.Writer;
+
+import org.apache.tika.sax.xpath.Matcher;
+import org.apache.tika.sax.xpath.MatchingContentHandler;
+import org.apache.tika.sax.xpath.XPathParser;
+import org.xml.sax.ContentHandler;
+
+/**
+ * Content handler decorator that only passes everything inside
+ * the XHTML &lt;body/&gt; tag to the underlying handler. Note that
+ * the &lt;body/&gt; tag itself is <em>not</em> passed on.
+ */
+public class BodyContentHandler extends ContentHandlerDecorator {
+
+    /**
+     * XHTML XPath parser.
+     */
+    private static final XPathParser PARSER =
+        new XPathParser("xhtml", XHTMLContentHandler.XHTML);
+
+    /**
+     * The XPath matcher used to select the XHTML body contents.
+     */
+    private static final Matcher MATCHER =
+        PARSER.parse("/xhtml:html/xhtml:body/descendant:node()");
+
+    /**
+     * Creates a content handler that passes all XHTML body events to the
+     * given underlying content handler.
+     *
+     * @param handler content handler
+     */
+    public BodyContentHandler(ContentHandler handler) {
+        super(new MatchingContentHandler(handler, MATCHER));
+    }
+
+    /**
+     * Creates a content handler that writes XHTML body character events to
+     * the given writer.
+     *
+     * @param writer writer
+     */
+    public BodyContentHandler(Writer writer) {
+        this(new XHTMLToTextContentHandler(new WriteOutContentHandler(writer)));
+    }
+
+    /**
+     * Creates a content handler that writes XHTML body character events to
+     * the given output stream using the default encoding.
+     *
+     * @param stream output stream
+     */
+    public BodyContentHandler(OutputStream stream) {
+        this(new XHTMLToTextContentHandler(new WriteOutContentHandler(stream)));
+    }
+
+    /**
+     * Creates a content handler that writes XHTML body character events to
+     * an internal string buffer. The contents of the buffer can be retrieved
+     * using the {@link #toString()} method.
+     */
+    public BodyContentHandler() {
+        this(new XHTMLToTextContentHandler(new WriteOutContentHandler()));
+    }
+
+}

Propchange: lucene/tika/trunk/src/main/java/org/apache/tika/sax/BodyContentHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: lucene/tika/trunk/src/main/java/org/apache/tika/sax/TextContentHandler.java
URL: http://svn.apache.org/viewvc/lucene/tika/trunk/src/main/java/org/apache/tika/sax/TextContentHandler.java?rev=721926&r1=721925&r2=721926&view=diff
==============================================================================
--- lucene/tika/trunk/src/main/java/org/apache/tika/sax/TextContentHandler.java (original)
+++ lucene/tika/trunk/src/main/java/org/apache/tika/sax/TextContentHandler.java Sun Nov 30 15:15:09 2008
@@ -1,54 +1,54 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tika.sax;
-
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.DefaultHandler;
-
-/**
- * Content handler decorator that only passes the
- * {@link #characters(char[], int, int)} and
- * (@link {@link #ignorableWhitespace(char[], int, int)} events to
- * the decorated content handler.
- */
-public class TextContentHandler extends DefaultHandler {
-
-    private final ContentHandler delegate;
-
-    public TextContentHandler(ContentHandler delegate) {
-        this.delegate = delegate;
-    }
-
-    @Override
-    public void characters(char[] ch, int start, int length)
-            throws SAXException {
-        delegate.characters(ch, start, length);
-    }
-
-    @Override
-    public void ignorableWhitespace(char[] ch, int start, int length)
-            throws SAXException {
-        delegate.ignorableWhitespace(ch, start, length);
-    }
-
-    @Override
-	public String toString() {
-        return delegate.toString();
-    }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tika.sax;
+
+import org.xml.sax.ContentHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ * Content handler decorator that only passes the
+ * {@link #characters(char[], int, int)} and
+ * (@link {@link #ignorableWhitespace(char[], int, int)} events to
+ * the decorated content handler.
+ */
+public class TextContentHandler extends DefaultHandler {
+
+    private final ContentHandler delegate;
+
+    public TextContentHandler(ContentHandler delegate) {
+        this.delegate = delegate;
+    }
+
+    @Override
+    public void characters(char[] ch, int start, int length)
+            throws SAXException {
+        delegate.characters(ch, start, length);
+    }
+
+    @Override
+    public void ignorableWhitespace(char[] ch, int start, int length)
+            throws SAXException {
+        delegate.ignorableWhitespace(ch, start, length);
+    }
+
+    @Override
+	public String toString() {
+        return delegate.toString();
+    }
+
+}

Propchange: lucene/tika/trunk/src/main/java/org/apache/tika/sax/TextContentHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: lucene/tika/trunk/src/main/java/org/apache/tika/sax/XHTMLToTextContentHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: lucene/tika/trunk/src/main/java/org/apache/tika/sax/xpath/AttributeMatcher.java
URL: http://svn.apache.org/viewvc/lucene/tika/trunk/src/main/java/org/apache/tika/sax/xpath/AttributeMatcher.java?rev=721926&r1=721925&r2=721926&view=diff
==============================================================================
--- lucene/tika/trunk/src/main/java/org/apache/tika/sax/xpath/AttributeMatcher.java (original)
+++ lucene/tika/trunk/src/main/java/org/apache/tika/sax/xpath/AttributeMatcher.java Sun Nov 30 15:15:09 2008
@@ -1,31 +1,31 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tika.sax.xpath;
-
-/**
- * Final evaluation state of a <code>.../@*</code> XPath expression.
- * Matches all attributes of the current element.
- */
-public class AttributeMatcher extends Matcher {
-
-    public static final Matcher INSTANCE = new AttributeMatcher();
-
-    public boolean matchesAttribute(String namespace, String name) {
-        return true;
-    }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tika.sax.xpath;
+
+/**
+ * Final evaluation state of a <code>.../@*</code> XPath expression.
+ * Matches all attributes of the current element.
+ */
+public class AttributeMatcher extends Matcher {
+
+    public static final Matcher INSTANCE = new AttributeMatcher();
+
+    public boolean matchesAttribute(String namespace, String name) {
+        return true;
+    }
+
+}

Propchange: lucene/tika/trunk/src/main/java/org/apache/tika/sax/xpath/AttributeMatcher.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: lucene/tika/trunk/src/main/java/org/apache/tika/sax/xpath/ChildMatcher.java
URL: http://svn.apache.org/viewvc/lucene/tika/trunk/src/main/java/org/apache/tika/sax/xpath/ChildMatcher.java?rev=721926&r1=721925&r2=721926&view=diff
==============================================================================
--- lucene/tika/trunk/src/main/java/org/apache/tika/sax/xpath/ChildMatcher.java (original)
+++ lucene/tika/trunk/src/main/java/org/apache/tika/sax/xpath/ChildMatcher.java Sun Nov 30 15:15:09 2008
@@ -1,35 +1,35 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tika.sax.xpath;
-
-/**
- * Intermediate evaluation state of a <code>.../*...</code> XPath expression.
- * Matches nothing, but specifies the evaluation state for all child elements.
- */
-public class ChildMatcher extends Matcher {
-
-    private final Matcher then;
-
-    public ChildMatcher(Matcher then) {
-        this.then = then;
-    }
-
-    public Matcher descend(String namespace, String name) {
-        return then;
-    }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tika.sax.xpath;
+
+/**
+ * Intermediate evaluation state of a <code>.../*...</code> XPath expression.
+ * Matches nothing, but specifies the evaluation state for all child elements.
+ */
+public class ChildMatcher extends Matcher {
+
+    private final Matcher then;
+
+    public ChildMatcher(Matcher then) {
+        this.then = then;
+    }
+
+    public Matcher descend(String namespace, String name) {
+        return then;
+    }
+
+}

Propchange: lucene/tika/trunk/src/main/java/org/apache/tika/sax/xpath/ChildMatcher.java
------------------------------------------------------------------------------
    svn:eol-style = native