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 2007/08/17 20:17:09 UTC

svn commit: r567100 [1/3] - in /incubator/tika/trunk/src: main/java/org/apache/tika/config/ main/java/org/apache/tika/exception/ main/java/org/apache/tika/log/ main/java/org/apache/tika/parser/ main/java/org/apache/tika/parser/html/ main/java/org/apach...

Author: jukka
Date: Fri Aug 17 11:17:06 2007
New Revision: 567100

URL: http://svn.apache.org/viewvc?view=rev&rev=567100
Log:
TIKA-7: Added the Lius Lite code from Rida. External dependencies are not included, need to update the POM with proper dependency settings.

Added:
    incubator/tika/trunk/src/main/java/org/apache/tika/config/
    incubator/tika/trunk/src/main/java/org/apache/tika/config/Content.java   (with props)
    incubator/tika/trunk/src/main/java/org/apache/tika/config/LiusConfig.java   (with props)
    incubator/tika/trunk/src/main/java/org/apache/tika/config/ParserConfig.java   (with props)
    incubator/tika/trunk/src/main/java/org/apache/tika/exception/
    incubator/tika/trunk/src/main/java/org/apache/tika/exception/LiusException.java   (with props)
    incubator/tika/trunk/src/main/java/org/apache/tika/log/
    incubator/tika/trunk/src/main/java/org/apache/tika/log/LiusLogger.java   (with props)
    incubator/tika/trunk/src/main/java/org/apache/tika/parser/
    incubator/tika/trunk/src/main/java/org/apache/tika/parser/Parser.java   (with props)
    incubator/tika/trunk/src/main/java/org/apache/tika/parser/ParserFactory.java   (with props)
    incubator/tika/trunk/src/main/java/org/apache/tika/parser/html/
    incubator/tika/trunk/src/main/java/org/apache/tika/parser/html/HtmlParser.java   (with props)
    incubator/tika/trunk/src/main/java/org/apache/tika/parser/msexcel/
    incubator/tika/trunk/src/main/java/org/apache/tika/parser/msexcel/ExcelExtractor.java   (with props)
    incubator/tika/trunk/src/main/java/org/apache/tika/parser/msexcel/MsExcelParser.java   (with props)
    incubator/tika/trunk/src/main/java/org/apache/tika/parser/mspowerpoint/
    incubator/tika/trunk/src/main/java/org/apache/tika/parser/mspowerpoint/ContentReaderListener.java   (with props)
    incubator/tika/trunk/src/main/java/org/apache/tika/parser/mspowerpoint/FilteredStringWriter.java   (with props)
    incubator/tika/trunk/src/main/java/org/apache/tika/parser/mspowerpoint/MsPowerPointParser.java   (with props)
    incubator/tika/trunk/src/main/java/org/apache/tika/parser/mspowerpoint/PPTConstants.java   (with props)
    incubator/tika/trunk/src/main/java/org/apache/tika/parser/mspowerpoint/PPTExtractor.java   (with props)
    incubator/tika/trunk/src/main/java/org/apache/tika/parser/mspowerpoint/Slide.java   (with props)
    incubator/tika/trunk/src/main/java/org/apache/tika/parser/mspowerpoint/TextBox.java   (with props)
    incubator/tika/trunk/src/main/java/org/apache/tika/parser/msword/
    incubator/tika/trunk/src/main/java/org/apache/tika/parser/msword/FastSavedException.java   (with props)
    incubator/tika/trunk/src/main/java/org/apache/tika/parser/msword/MsWordParser.java   (with props)
    incubator/tika/trunk/src/main/java/org/apache/tika/parser/msword/PasswordProtectedException.java   (with props)
    incubator/tika/trunk/src/main/java/org/apache/tika/parser/msword/Word6Extractor.java   (with props)
    incubator/tika/trunk/src/main/java/org/apache/tika/parser/msword/WordExtractor.java   (with props)
    incubator/tika/trunk/src/main/java/org/apache/tika/parser/msword/WordTextBuffer.java   (with props)
    incubator/tika/trunk/src/main/java/org/apache/tika/parser/msword/WordTextPiece.java   (with props)
    incubator/tika/trunk/src/main/java/org/apache/tika/parser/msword/chp/
    incubator/tika/trunk/src/main/java/org/apache/tika/parser/msword/chp/Word6CHPBinTable.java   (with props)
    incubator/tika/trunk/src/main/java/org/apache/tika/parser/opendocument/
    incubator/tika/trunk/src/main/java/org/apache/tika/parser/opendocument/OpenOfficeEntityResolver.java   (with props)
    incubator/tika/trunk/src/main/java/org/apache/tika/parser/opendocument/OpenOfficeParser.java   (with props)
    incubator/tika/trunk/src/main/java/org/apache/tika/parser/pdf/
    incubator/tika/trunk/src/main/java/org/apache/tika/parser/pdf/PDFParser.java   (with props)
    incubator/tika/trunk/src/main/java/org/apache/tika/parser/rtf/
    incubator/tika/trunk/src/main/java/org/apache/tika/parser/rtf/RTFParser.java   (with props)
    incubator/tika/trunk/src/main/java/org/apache/tika/parser/txt/
    incubator/tika/trunk/src/main/java/org/apache/tika/parser/txt/TXTParser.java   (with props)
    incubator/tika/trunk/src/main/java/org/apache/tika/parser/xml/
    incubator/tika/trunk/src/main/java/org/apache/tika/parser/xml/XMLParser.java   (with props)
    incubator/tika/trunk/src/main/java/org/apache/tika/utils/
    incubator/tika/trunk/src/main/java/org/apache/tika/utils/MSExtractor.java   (with props)
    incubator/tika/trunk/src/main/java/org/apache/tika/utils/MimeTypesUtils.java   (with props)
    incubator/tika/trunk/src/main/java/org/apache/tika/utils/RegexUtils.java   (with props)
    incubator/tika/trunk/src/main/java/org/apache/tika/utils/Utils.java   (with props)
    incubator/tika/trunk/src/main/resources/
    incubator/tika/trunk/src/main/resources/config.xml   (with props)
    incubator/tika/trunk/src/main/resources/log4j/
    incubator/tika/trunk/src/main/resources/log4j/log4j.properties   (with props)
    incubator/tika/trunk/src/test/
    incubator/tika/trunk/src/test/java/
    incubator/tika/trunk/src/test/java/org/
    incubator/tika/trunk/src/test/java/org/apache/
    incubator/tika/trunk/src/test/java/org/apache/tika/
    incubator/tika/trunk/src/test/java/org/apache/tika/TestParsers.java   (with props)
    incubator/tika/trunk/src/test/resources/
    incubator/tika/trunk/src/test/resources/testHTML.html   (with props)
    incubator/tika/trunk/src/test/resources/testRTF.rtf
    incubator/tika/trunk/src/test/resources/testTXT.txt   (with props)
    incubator/tika/trunk/src/test/resources/testXML.xml   (with props)

Added: incubator/tika/trunk/src/main/java/org/apache/tika/config/Content.java
URL: http://svn.apache.org/viewvc/incubator/tika/trunk/src/main/java/org/apache/tika/config/Content.java?view=auto&rev=567100
==============================================================================
--- incubator/tika/trunk/src/main/java/org/apache/tika/config/Content.java (added)
+++ incubator/tika/trunk/src/main/java/org/apache/tika/config/Content.java Fri Aug 17 11:17:06 2007
@@ -0,0 +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.config;
+
+/**
+ * Content object, used to configure and store data pupulated from XPATH, Regex, Document fulltext, document metadata etc.  
+ * @author Rida Benjelloun (ridabenjelloun@apache.org)  
+ */
+public class Content {
+    
+    private String name;
+    private String value;
+    private String[] values;
+    private String textSelect;
+    private String xPathSelect;
+    private String regexSelect;
+    
+    
+    public String getName() {
+        return name;
+    }
+    public void setName(String name) {
+        this.name = name;
+    }
+    public String getRegexSelect() {
+        return regexSelect;
+    }
+    public void setRegexSelect(String regexSelect) {
+        this.regexSelect = regexSelect;
+    }
+    public String getTextSelect() {
+        return textSelect;
+    }
+    public void setTextSelect(String select) {
+        this.textSelect = select;
+    }
+    public String getValue() {
+        return value;
+    }
+    public void setValue(String value) {
+        this.value = value;
+    }
+    public String getXPathSelect() {
+        return xPathSelect;
+    }
+    public void setXPathSelect(String pathSelect) {
+        xPathSelect = pathSelect;
+    }
+    public String[] getValues() {
+        return values;
+    }
+    public void setValues(String[] values) {
+        this.values = values;
+    }
+
+
+}

Propchange: incubator/tika/trunk/src/main/java/org/apache/tika/config/Content.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/tika/trunk/src/main/java/org/apache/tika/config/LiusConfig.java
URL: http://svn.apache.org/viewvc/incubator/tika/trunk/src/main/java/org/apache/tika/config/LiusConfig.java?view=auto&rev=567100
==============================================================================
--- incubator/tika/trunk/src/main/java/org/apache/tika/config/LiusConfig.java (added)
+++ incubator/tika/trunk/src/main/java/org/apache/tika/config/LiusConfig.java Fri Aug 17 11:17:06 2007
@@ -0,0 +1,156 @@
+/**
+ * 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.config;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jdom.JDOMException;
+import org.jdom.input.SAXBuilder;
+import org.jdom.xpath.XPath;
+
+/**
+ * Parse xml config file. Use cache mecanisme to store multiple configs   
+ * @author Rida Benjelloun (ridabenjelloun@apache.org)  
+ */
+public class LiusConfig {
+
+    static Logger logger = Logger.getRootLogger();
+
+    private static Map configsCache = new HashMap<String, LiusConfig>();
+
+    private static List<ParserConfig> parsersConfigs;
+
+    private static LiusConfig tc;
+
+    private LiusConfig() {
+    }
+
+    private static String currentFile;
+
+    public static LiusConfig getInstance(String configFile) {
+
+        if (configsCache.containsKey(configFile)) {
+            return (LiusConfig) configsCache.get(configFile);
+
+        } else {
+            Document doc = parse(configFile);
+
+            tc = new LiusConfig();
+
+            populateConfig(doc, tc);
+
+            configsCache.put(configFile, tc);
+        }
+        currentFile = configFile;
+        return tc;
+    }
+
+    public List<ParserConfig> getParsersConfigs() {
+        return parsersConfigs;
+    }
+
+    public void setParsersConfigs(List<ParserConfig> parsersConfigs) {
+        this.parsersConfigs = parsersConfigs;
+    }
+
+    public ParserConfig getParserConfig(String mimeType) {
+        ParserConfig pc = null;
+        for (int i = 0; i < parsersConfigs.size(); i++) {
+            if (((ParserConfig) parsersConfigs.get(i)).getMimes().containsKey(
+                    mimeType)) {
+                return (ParserConfig) parsersConfigs.get(i);
+            }
+        }
+        return pc;
+    }
+
+    private static Document parse(String file) {
+        org.jdom.Document xmlDoc = new org.jdom.Document();
+        try {
+            SAXBuilder builder = new SAXBuilder();
+            xmlDoc = builder.build(new File(file));
+        } catch (JDOMException e) {
+            logger.error(e.getMessage());
+        } catch (IOException e) {
+            logger.error(e.getMessage());
+        }
+        return xmlDoc;
+
+    }
+
+    private static void populateConfig(Document doc, LiusConfig tc) {
+        parsersConfigs = new ArrayList<ParserConfig>();
+        try {
+            List parsersList = XPath.selectNodes(doc, "//parser");
+            for (int i = 0; i < parsersList.size(); i++) {
+                ParserConfig pc = new ParserConfig();
+                Element parserElem = (Element) parsersList.get(i);
+                pc.setName(parserElem.getAttributeValue("name"));
+                pc.setParserClass(parserElem.getAttributeValue("class"));
+                if (parserElem.getChild("namespace") != null) {
+                    pc.setNameSpace(parserElem.getChild("namespace")
+                            .getTextTrim());
+                }
+                Map<String, String> mimes = new HashMap<String, String>();
+                List mimesElems = parserElem.getChildren("mime");
+                for (int j = 0; j < mimesElems.size(); j++) {
+                    String mime = ((Element) mimesElems.get(j)).getTextTrim();
+                    mimes.put(mime, null);
+                }
+                pc.setMimes(mimes);
+                List<Content> contents = new ArrayList<Content>();
+                if (parserElem.getChild("extract") != null) {
+                    List contentsElems = parserElem.getChild("extract")
+                            .getChildren();
+                    for (int j = 0; j < contentsElems.size(); j++) {
+                        Content content = new Content();
+                        Element contentElem = (Element) contentsElems.get(j);
+                        content.setName(contentElem.getAttributeValue("name"));
+                        if (contentElem.getAttribute("xpathSelect") != null) {
+                            content.setXPathSelect(contentElem
+                                    .getAttributeValue("xpathSelect"));
+                        }
+                        if (contentElem.getAttribute("textSelect") != null) {
+                            content.setTextSelect(contentElem
+                                    .getAttributeValue("textSelect"));
+                        }
+                        if (contentElem.getChild("regexSelect") != null) {
+                            content.setRegexSelect(contentElem.getChild(
+                                    "regexSelect").getTextTrim());
+                        }
+                        contents.add(content);
+                    }
+                }
+                pc.setContents(contents);
+                parsersConfigs.add(pc);
+            }
+        } catch (JDOMException e) {
+            logger.error(e.getMessage());
+        }
+        tc.setParsersConfigs(parsersConfigs);
+
+    }
+
+}

Propchange: incubator/tika/trunk/src/main/java/org/apache/tika/config/LiusConfig.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/tika/trunk/src/main/java/org/apache/tika/config/ParserConfig.java
URL: http://svn.apache.org/viewvc/incubator/tika/trunk/src/main/java/org/apache/tika/config/ParserConfig.java?view=auto&rev=567100
==============================================================================
--- incubator/tika/trunk/src/main/java/org/apache/tika/config/ParserConfig.java (added)
+++ incubator/tika/trunk/src/main/java/org/apache/tika/config/ParserConfig.java Fri Aug 17 11:17:06 2007
@@ -0,0 +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.config;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Store all the informations regarding specific parser   
+ * @author Rida Benjelloun (ridabenjelloun@apache.org)  
+ */
+public class ParserConfig {
+
+    private String name;
+
+    private String parserClass;
+
+    private Map<String, String> mimes;
+
+    private String nameSpace;
+
+    private List<Content> contents;
+
+    public List<Content> getContents() {
+        return contents;
+    }
+
+    public void setContents(List<Content> contents) {
+        this.contents = contents;
+    }
+
+    public Map<String, String> getMimes() {
+        return mimes;
+    }
+
+    public void setMimes(Map<String, String> mimes) {
+        this.mimes = mimes;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getNameSpace() {
+        return nameSpace;
+    }
+
+    public void setNameSpace(String nameSpace) {
+        this.nameSpace = nameSpace;
+    }
+
+    public String getParserClass() {
+        return parserClass;
+    }
+
+    public void setParserClass(String parserClass) {
+        this.parserClass = parserClass;
+    }
+
+}

Propchange: incubator/tika/trunk/src/main/java/org/apache/tika/config/ParserConfig.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/tika/trunk/src/main/java/org/apache/tika/exception/LiusException.java
URL: http://svn.apache.org/viewvc/incubator/tika/trunk/src/main/java/org/apache/tika/exception/LiusException.java?view=auto&rev=567100
==============================================================================
--- incubator/tika/trunk/src/main/java/org/apache/tika/exception/LiusException.java (added)
+++ incubator/tika/trunk/src/main/java/org/apache/tika/exception/LiusException.java Fri Aug 17 11:17:06 2007
@@ -0,0 +1,29 @@
+/**
+ * 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.exception;
+
+/**
+ * Lius exception 
+ * @author Rida Benjelloun (ridabenjelloun@apache.org)  
+ */
+public class LiusException extends Exception {
+
+    public LiusException(String msg) {
+        super(msg);
+    }
+
+}

Propchange: incubator/tika/trunk/src/main/java/org/apache/tika/exception/LiusException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/tika/trunk/src/main/java/org/apache/tika/log/LiusLogger.java
URL: http://svn.apache.org/viewvc/incubator/tika/trunk/src/main/java/org/apache/tika/log/LiusLogger.java?view=auto&rev=567100
==============================================================================
--- incubator/tika/trunk/src/main/java/org/apache/tika/log/LiusLogger.java (added)
+++ incubator/tika/trunk/src/main/java/org/apache/tika/log/LiusLogger.java Fri Aug 17 11:17:06 2007
@@ -0,0 +1,34 @@
+/**
+ * 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.log;
+
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.log4j.PropertyConfigurator;
+
+/**
+ * Lius Logger  
+ * @author Rida Benjelloun (ridabenjelloun@apache.org)  
+ */
+public class LiusLogger {
+    static Logger logger = Logger.getLogger("TikaLogger");
+
+    public static void setLoggerConfigFile(String loggerConfigPath) {
+        PropertyConfigurator.configure(loggerConfigPath);
+        logger.setLevel(((Level) Level.ERROR));
+    }
+}

Propchange: incubator/tika/trunk/src/main/java/org/apache/tika/log/LiusLogger.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/tika/trunk/src/main/java/org/apache/tika/parser/Parser.java
URL: http://svn.apache.org/viewvc/incubator/tika/trunk/src/main/java/org/apache/tika/parser/Parser.java?view=auto&rev=567100
==============================================================================
--- incubator/tika/trunk/src/main/java/org/apache/tika/parser/Parser.java (added)
+++ incubator/tika/trunk/src/main/java/org/apache/tika/parser/Parser.java Fri Aug 17 11:17:06 2007
@@ -0,0 +1,98 @@
+/**
+ * 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;
+
+import java.io.InputStream;
+import java.util.List;
+
+import org.apache.tika.config.Content;
+import org.apache.tika.config.LiusConfig;
+import org.apache.tika.config.ParserConfig;
+import org.apache.tika.exception.LiusException;
+
+/**
+ * Abstract class Parser
+ * 
+ * @author Rida Benjelloun (ridabenjelloun@apache.org)
+ */
+public abstract class Parser {
+
+    private InputStream is;
+
+    private ParserConfig pc;
+
+    private String mimeType;
+
+    public void setInputStream(InputStream is) {
+        this.is = is;
+    }
+
+    public InputStream getInputStream() {
+        return is;
+    }
+
+    /**
+     * Configure parsers from mimetypes
+     */
+    public void configure(LiusConfig config) throws LiusException {
+        pc = config.getParserConfig(getMimeType());
+        if (pc.equals(null)) {
+            throw new LiusException("Please Configure your parser ");
+        }
+    }
+
+    /**
+     * Return parser specific config
+     */
+    public ParserConfig getParserConfig() {
+        return pc;
+    }
+
+    /**
+     * Get document mime type
+     */
+    public String getMimeType() {
+        return mimeType;
+    }
+
+    /**
+     * Set document mime type
+     */
+    public void setMimeType(String mimeType) {
+        this.mimeType = mimeType;
+    }
+
+    /**
+     * Get the string content of the document
+     */
+    public abstract String getStrContent();
+
+    /**
+     * Get a content object, this object is configured from the LiusConfig Xml.
+     * It could be a document metadata, XPath selection, regex selection or
+     * fulltext
+     */
+    public abstract Content getContent(String name);
+
+    /**
+     * Get a List of contents objects, this objects are configured from the
+     * LiusConfig Xml file. It could be a document metadata, XPath selection,
+     * regex selection or fulltext
+     */
+    public abstract List<Content> getContents();
+
+}

Propchange: incubator/tika/trunk/src/main/java/org/apache/tika/parser/Parser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/tika/trunk/src/main/java/org/apache/tika/parser/ParserFactory.java
URL: http://svn.apache.org/viewvc/incubator/tika/trunk/src/main/java/org/apache/tika/parser/ParserFactory.java?view=auto&rev=567100
==============================================================================
--- incubator/tika/trunk/src/main/java/org/apache/tika/parser/ParserFactory.java (added)
+++ incubator/tika/trunk/src/main/java/org/apache/tika/parser/ParserFactory.java Fri Aug 17 11:17:06 2007
@@ -0,0 +1,101 @@
+/**
+ * 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;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+
+import org.apache.tika.config.LiusConfig;
+import org.apache.tika.config.ParserConfig;
+import org.apache.tika.exception.LiusException;
+import org.apache.tika.utils.MimeTypesUtils;
+import net.hedges.mimeinfo.MimeInfoException;
+
+import org.apache.log4j.Logger;
+
+/**
+ * Factory class. Build parser from xml config file.
+ * 
+ * @author Rida Benjelloun (ridabenjelloun@apache.org)
+ */
+public class ParserFactory {
+
+    static Logger logger = Logger.getRootLogger();
+
+    /**
+     * Build parser from file and Lius config object
+     */
+    public static Parser getParser(File file, LiusConfig tc)
+            throws MimeInfoException, IOException, LiusException {
+        String mimeType = MimeTypesUtils.getMimeType(file);
+        ParserConfig pc = tc.getParserConfig(mimeType);
+        String className = pc.getParserClass();
+        Parser parser = null;
+        Class<?> parserClass = null;
+        if (className != null) {
+            try {
+                logger.info("Loading parser class = " + className
+                        + " MimeType = " + mimeType);
+
+                parserClass = Class.forName(className);
+                parser = (Parser) parserClass.newInstance();
+
+            } catch (ClassNotFoundException e) {
+                logger.error(e.getMessage());
+
+            } catch (InstantiationException e) {
+                logger.error(e.getMessage());
+            } catch (IllegalAccessException e) {
+                logger.error(e.getMessage());
+            }
+            parser.setMimeType(mimeType);
+            parser.configure(tc);
+            parser.setInputStream(new FileInputStream(file));
+
+        }
+
+        return parser;
+    }
+
+    /**
+     * Build parser from string file path and Lius config object
+     */
+    public static Parser getParser(String str, LiusConfig tc)
+            throws MimeInfoException, IOException, LiusException {
+        return getParser(new File(str), tc);
+    }
+
+    /**
+     * Build parser from string file path and Lius config file path
+     */
+    public static Parser getParser(String str, String tcPath)
+            throws MimeInfoException, IOException, LiusException {
+        LiusConfig tc = LiusConfig.getInstance(tcPath);
+        return getParser(new File(str), tc);
+    }
+
+    /**
+     * Build parser from file and Lius config file path
+     */
+    public static Parser getParser(File file, String tcPath)
+            throws MimeInfoException, IOException, LiusException {
+        LiusConfig tc = LiusConfig.getInstance(tcPath);
+        return getParser(file, tc);
+    }
+
+}

Propchange: incubator/tika/trunk/src/main/java/org/apache/tika/parser/ParserFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/tika/trunk/src/main/java/org/apache/tika/parser/html/HtmlParser.java
URL: http://svn.apache.org/viewvc/incubator/tika/trunk/src/main/java/org/apache/tika/parser/html/HtmlParser.java?view=auto&rev=567100
==============================================================================
--- incubator/tika/trunk/src/main/java/org/apache/tika/parser/html/HtmlParser.java (added)
+++ incubator/tika/trunk/src/main/java/org/apache/tika/parser/html/HtmlParser.java Fri Aug 17 11:17:06 2007
@@ -0,0 +1,159 @@
+/**
+ * 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.html;
+
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tika.config.Content;
+import org.apache.tika.parser.Parser;
+import org.apache.tika.utils.RegexUtils;
+
+import org.apache.log4j.Logger;
+import org.apache.oro.text.regex.MalformedPatternException;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+import org.w3c.tidy.Tidy;
+
+/**
+ * Html parser
+ * @author Rida Benjelloun (ridabenjelloun@apache.org)
+ */
+public class HtmlParser extends Parser {
+
+    static Logger logger = Logger.getRootLogger();
+
+    private Node root = null;
+
+    private String contentStr;
+
+    private Map<String, Content> contentsMap;
+
+    public Content getContent(String name) {
+        if (contentsMap == null || contentsMap.isEmpty()) {
+            getContents();
+        }
+        return contentsMap.get(name);
+    }
+
+    public List<Content> getContents() {
+        if (contentStr == null) {
+            contentStr = getStrContent();
+        }
+        List<Content> ctt = getParserConfig().getContents();
+        contentsMap = new HashMap<String, Content>();
+        Iterator i = ctt.iterator();
+        while (i.hasNext()) {
+            Content ct = (Content) i.next();
+            if (ct.getTextSelect() != null) {
+                if (ct.getTextSelect().equalsIgnoreCase("fulltext")) {
+                    ct.setValue(contentStr);
+                } else {
+                    extractElementTxt((Element) root, ct);
+                }
+
+            }
+
+            else if (ct.getRegexSelect() != null) {
+                try {
+                    List<String> valuesLs = RegexUtils.extract(contentStr, ct
+                            .getRegexSelect());
+                    if (valuesLs.size() > 0) {
+                        ct.setValue(valuesLs.get(0));
+                        ct.setValues(valuesLs.toArray(new String[0]));
+                    }
+                } catch (MalformedPatternException e) {
+                    logger.error(e.getMessage());
+                }
+            }
+            contentsMap.put(ct.getName(), ct);
+        }
+
+        return getParserConfig().getContents();
+
+    }
+
+    public String getStrContent() {
+        if (root == null)
+            root = getRoot(getInputStream());
+        contentStr = getTextContent(root);
+        return contentStr;
+    }
+
+    private Node getRoot(InputStream is) {
+        Tidy tidy = new Tidy();
+        tidy.setQuiet(true);
+        tidy.setShowWarnings(false);
+        org.w3c.dom.Document doc = tidy.parseDOM(is, null);
+        return doc.getDocumentElement();
+    }
+
+    private void extractElementTxt(Element root, Content content) {
+
+        NodeList children = root.getElementsByTagName(content.getName());
+        if (children != null) {
+            if (children.getLength() > 0) {
+                if (children.getLength() == 1) {
+                    Element node = (Element) children.item(0);
+                    Text txt = (Text) node.getFirstChild();
+                    if (txt != null) {
+                        content.setValue(txt.getData());
+
+                    }
+                } else {
+                    String[] values = new String[100];
+                    for (int i = 0; i < children.getLength(); i++) {
+                        Element node = (Element) children.item(i);
+                        Text txt = (Text) node.getFirstChild();
+                        if (txt != null) {
+                            values[i] = txt.getData();
+                        }
+                    }
+                    if (values.length > 0) {
+                        content.setValue(values[0]);
+                        content.setValues(values);
+                    }
+                }
+            }
+        }
+
+    }
+
+    private String getTextContent(Node node) {
+        NodeList children = node.getChildNodes();
+        StringBuffer sb = new StringBuffer();
+        for (int i = 0; i < children.getLength(); i++) {
+            Node child = children.item(i);
+            switch (child.getNodeType()) {
+            case Node.ELEMENT_NODE:
+                sb.append(getTextContent(child));
+                sb.append(" ");
+                break;
+            case Node.TEXT_NODE:
+                sb.append(((Text) child).getData());
+                break;
+            }
+        }
+        return sb.toString();
+    }
+
+}

Propchange: incubator/tika/trunk/src/main/java/org/apache/tika/parser/html/HtmlParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/tika/trunk/src/main/java/org/apache/tika/parser/msexcel/ExcelExtractor.java
URL: http://svn.apache.org/viewvc/incubator/tika/trunk/src/main/java/org/apache/tika/parser/msexcel/ExcelExtractor.java?view=auto&rev=567100
==============================================================================
--- incubator/tika/trunk/src/main/java/org/apache/tika/parser/msexcel/ExcelExtractor.java (added)
+++ incubator/tika/trunk/src/main/java/org/apache/tika/parser/msexcel/ExcelExtractor.java Fri Aug 17 11:17:06 2007
@@ -0,0 +1,93 @@
+/**
+ * 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.msexcel;
+
+// JDK imports
+import java.io.InputStream;
+
+import org.apache.tika.utils.MSExtractor;
+
+// Jakarta POI imports
+import org.apache.poi.hssf.usermodel.HSSFCell;
+import org.apache.poi.hssf.usermodel.HSSFRow;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+
+
+
+/**
+ * Excel Text and Properties extractor.
+ *
+ * @author Rohit Kulkarni & Ashish Vaidya
+ * @author J&eacute;r&ocirc;me Charron
+ */
+class ExcelExtractor extends MSExtractor {
+
+  
+  public String extractText(InputStream input) throws Exception {
+    
+    String resultText = "";
+    HSSFWorkbook wb = new HSSFWorkbook(input);
+    if (wb == null) {
+      return resultText;
+    }
+    
+    HSSFSheet sheet;
+    HSSFRow row;
+    HSSFCell cell;
+    int sNum = 0;
+    int rNum = 0;
+    int cNum = 0;
+    
+    sNum = wb.getNumberOfSheets();
+    
+    for (int i=0; i<sNum; i++) {
+      if ((sheet = wb.getSheetAt(i)) == null) {
+        continue;
+      }
+      rNum = sheet.getLastRowNum();
+      for (int j=0; j<=rNum; j++) {
+        if ((row = sheet.getRow(j)) == null){
+          continue;
+        }
+        cNum = row.getLastCellNum();
+        
+        for (int k=0; k<cNum; k++) {
+          if ((cell = row.getCell((short) k)) != null) {
+            /*if(HSSFDateUtil.isCellDateFormatted(cell) == true) {
+                resultText += cell.getDateCellValue().toString() + " ";
+              } else
+             */
+            if (cell.getCellType() == HSSFCell.CELL_TYPE_STRING) {
+              resultText += cell.getStringCellValue() + " ";
+            } else if (cell.getCellType() == HSSFCell.CELL_TYPE_NUMERIC) {
+              Double d = new Double(cell.getNumericCellValue());
+              resultText += d.toString() + " ";
+            }
+            /* else if(cell.getCellType() == HSSFCell.CELL_TYPE_FORMULA){
+                 resultText += cell.getCellFormula() + " ";
+               } 
+             */
+          }
+        }
+      }
+    }
+    return resultText;
+  }
+  
+}
+

Propchange: incubator/tika/trunk/src/main/java/org/apache/tika/parser/msexcel/ExcelExtractor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/tika/trunk/src/main/java/org/apache/tika/parser/msexcel/MsExcelParser.java
URL: http://svn.apache.org/viewvc/incubator/tika/trunk/src/main/java/org/apache/tika/parser/msexcel/MsExcelParser.java?view=auto&rev=567100
==============================================================================
--- incubator/tika/trunk/src/main/java/org/apache/tika/parser/msexcel/MsExcelParser.java (added)
+++ incubator/tika/trunk/src/main/java/org/apache/tika/parser/msexcel/MsExcelParser.java Fri Aug 17 11:17:06 2007
@@ -0,0 +1,96 @@
+/**
+ * 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.msexcel;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tika.config.Content;
+import org.apache.tika.parser.Parser;
+import org.apache.tika.utils.MSExtractor;
+import org.apache.tika.utils.RegexUtils;
+
+import org.apache.log4j.Logger;
+import org.apache.oro.text.regex.MalformedPatternException;
+
+/**
+ * Excel parser
+ * 
+ * @author Rida Benjelloun (ridabenjelloun@apache.org)
+ */
+public class MsExcelParser extends Parser {
+    private MSExtractor extrator = new ExcelExtractor();
+
+    private String contentStr;
+
+    private Map<String, Content> contentsMap;
+
+    static Logger logger = Logger.getRootLogger();
+
+    public Content getContent(String name) {
+        if (contentsMap == null || contentsMap.isEmpty()) {
+            getContents();
+        }
+        return contentsMap.get(name);
+    }
+
+    public List<Content> getContents() {
+        if (contentStr == null) {
+            contentStr = getStrContent();
+        }
+        List<Content> ctt = getParserConfig().getContents();
+        contentsMap = new HashMap<String, Content>();
+        Iterator i = ctt.iterator();
+        while (i.hasNext()) {
+            Content ct = (Content) i.next();
+            if (ct.getTextSelect() != null) {
+                if (ct.getTextSelect().equalsIgnoreCase("fulltext")) {
+                    ct.setValue(contentStr);
+                }
+
+            } else if (ct.getRegexSelect() != null) {
+                try {
+                    List<String> valuesLs = RegexUtils.extract(contentStr, ct
+                            .getRegexSelect());
+                    if (valuesLs.size() > 0) {
+                        ct.setValue(valuesLs.get(0));
+                        ct.setValues(valuesLs.toArray(new String[0]));
+                    }
+                } catch (MalformedPatternException e) {
+                    logger.error(e.getMessage());
+                }
+            }
+            contentsMap.put(ct.getName(), ct);
+        }
+
+        return getParserConfig().getContents();
+
+    }
+
+    public String getStrContent() {
+        // extrator.setContents(getParserConfig().getContents());
+        try {
+            contentStr = extrator.extractText(getInputStream());
+        } catch (Exception e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        return contentStr;
+    }
+}

Propchange: incubator/tika/trunk/src/main/java/org/apache/tika/parser/msexcel/MsExcelParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/tika/trunk/src/main/java/org/apache/tika/parser/mspowerpoint/ContentReaderListener.java
URL: http://svn.apache.org/viewvc/incubator/tika/trunk/src/main/java/org/apache/tika/parser/mspowerpoint/ContentReaderListener.java?view=auto&rev=567100
==============================================================================
--- incubator/tika/trunk/src/main/java/org/apache/tika/parser/mspowerpoint/ContentReaderListener.java (added)
+++ incubator/tika/trunk/src/main/java/org/apache/tika/parser/mspowerpoint/ContentReaderListener.java Fri Aug 17 11:17:06 2007
@@ -0,0 +1,468 @@
+/**
+ * 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.mspowerpoint;
+
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Vector;
+
+import org.apache.log4j.Logger;
+import org.apache.poi.hdf.extractor.Utils;
+import org.apache.poi.poifs.eventfilesystem.POIFSReaderEvent;
+import org.apache.poi.poifs.eventfilesystem.POIFSReaderListener;
+import org.apache.poi.poifs.filesystem.DocumentInputStream;
+import org.apache.poi.util.LittleEndian;
+import org.apache.poi.util.StringUtil;
+
+/**
+ * Listener to read the content of PowerPoint file and transfere it to the
+ * passed <code>StringBuffer</code>.
+ * 
+ * @author Stephan Strittmatter - http://www.sybit.de
+ * 
+ * @version 1.0
+ * 
+ */
+class ContentReaderListener implements POIFSReaderListener {
+
+    static Logger LOG = Logger.getRootLogger();
+
+    /** Buffer holding the content of the file */
+    protected final transient StringBuffer buf;
+
+    /**
+     * Constructs Listener to get content of PowerPoint file.
+     * 
+     * @param content
+     *            StringBuffer refereing the content of the PowerPoint file.
+     */
+    public ContentReaderListener(final StringBuffer content) {
+        this.buf = content;
+    }
+
+    /**
+     * Reads the internal PowerPoint document stream.
+     * 
+     * @see org.apache.poi.poifs.eventfilesystem.POIFSReaderListener#processPOIFSReaderEvent(org.apache.poi.poifs.eventfilesystem.POIFSReaderEvent)
+     */
+    public void processPOIFSReaderEvent(final POIFSReaderEvent event) {
+
+        if (event == null
+                || event.getName() == null
+                || !event.getName()
+                        .startsWith(PPTConstants.POWERPOINT_DOCUMENT)) {
+
+            LOG
+                    .warn("Stream not processed. It is not a PowerPoint document: : "
+                            + event.getName());
+
+            return;
+        }
+
+        try {
+            final DocumentInputStream dis = event.getStream();
+            final byte pptdata[] = new byte[dis.available()];
+            dis.read(pptdata, 0, dis.available());
+            int offset = 0;
+            long offsetPD = 0;
+
+            /*
+             * Traverse Bytearray to get CurrentUserEditAtom Call to extract the
+             * Text in all PlaceHolders to hold PPTClientTextBox objects for
+             * mapping into Slide Objects
+             */
+            Hashtable/* <Long, TextBox> */containerTextBox = new Hashtable/*
+                                                                             * <Long,
+                                                                             * TextBox>
+                                                                             */();
+            // Traverse ByteArray to identiy edit paths of ClientTextBoxes
+            long n = pptdata.length - 20;
+            for (long i = 0; i < n; i++) {
+
+                final long type = LittleEndian.getUShort(pptdata, (int) i + 2);
+                // final long size = LittleEndian.getUInt(pptdata, (int) i + 4);
+
+                if (PPTConstants.PPT_ATOM_USEREDIT == type) {
+                    /*
+                     * Checking the Record Header (UserEditAtom)
+                     */
+                    // final long lastSlideID = LittleEndian.getInt(pptdata,
+                    // (int) i + 8);
+                    // final long version = LittleEndian.getUInt(pptdata, (int)
+                    // i + 12);
+                    offset = (int) LittleEndian.getUInt(pptdata, (int) i + 16);
+                    offsetPD = LittleEndian.getUInt(pptdata, (int) i + 20);
+
+                    /*
+                     * Call to extract ClientTextBox text in each UserEditAtom
+                     */
+                    containerTextBox = extractTextBoxes(containerTextBox,
+                            offset, pptdata, offsetPD);
+                } else if (PPTConstants.PPT_ATOM_DRAWINGGROUP == type) {
+                    // if (LOG.isTraceEnabled()) {
+                    // LOG.trace("PPT_DRAWINGGROUP_ATOM ignored: " + type);
+                    // }
+                } else if (PPTConstants.PPT_ATOM_TEXTBYTE == type) {
+                    // if (LOG.isTraceEnabled()) {
+                    // LOG.trace("PPT_TEXTBYTE_ATOM ignored: " + type);
+                    // }
+                } else if (PPTConstants.PPT_ATOM_TEXTCHAR == type) {
+                    // if (LOG.isTraceEnabled()) {
+                    // LOG.trace("PPT_TEXTCHAR_ATOM ignored: " + type);
+                    // }
+                } else {
+                    // no action
+                    // if (LOG.isTraceEnabled()) {
+                    // LOG.trace("type not handled: " + type);
+                    // }
+                }
+            }
+
+            final List/* <PPTSlide> */slides = extractSlides(offset, pptdata,
+                    offsetPD);
+
+            if (slides.size() == 0) {
+                if (LOG.isInfoEnabled()) {
+                    LOG.info("No slides extracted!");
+                }
+
+            } else {
+                Slide slide = (Slide) slides.get(slides.size() - 1);
+
+                for (Enumeration enumeration = containerTextBox.elements(); enumeration
+                        .hasMoreElements();) {
+                    final TextBox textBox = (TextBox) enumeration.nextElement();
+                    slide.addContent(textBox.getContent());
+                }
+
+                /*
+                 * Merging TextBox data with Slide Data Printing the text from
+                 * Slides vector object.
+                 */
+                List scontent;
+                for (int i = 0; i < slides.size(); i++) {
+                    slide = (Slide) slides.get(i);
+                    scontent = slide.getContent();
+                    String contentText;
+
+                    for (int j = 0; j < scontent.size(); j++) {
+                        contentText = scontent.get(j).toString();
+                        this.buf.append(contentText);
+
+                        // to avoid concatinated words we add a blank additional
+                        if (contentText.length() > 0
+                                && !(contentText.endsWith("\r") || contentText
+                                        .endsWith("\n"))) {
+                            this.buf.append(" ");
+                        }
+                    }
+                }
+            }
+        } catch (Throwable ex) {
+            // because of not killing complete crawling all Throwables are
+            // catched.
+
+            LOG.error("processPOIFSReaderEvent", ex);
+        }
+    }
+
+    /**
+     * Extracts the client text boxes of a slide.
+     * 
+     * @param containerTextBox
+     * @param offset
+     * @param pptdata
+     * @param offsetPD
+     * @return Hashtable
+     * @see TextBox
+     */
+    protected Hashtable/* <Long, TextBox> */extractTextBoxes(
+            final Hashtable/* <Long, TextBox> */containerTextBox,
+            final int offset, final byte[] pptdata, final long offsetPD) {
+
+        // To hold temporary data
+        FilteredStringWriter outStream = new FilteredStringWriter();
+
+        TextBox textBox;
+
+        // Traversing the bytearray up to Presist directory position
+        for (int i = offset; i < offsetPD - 20; i++) {
+            try {
+                // Record info
+                // final long rinfo = LittleEndian.getUShort(pptdata, (int) i);
+                // Record Type
+                final long recordType = LittleEndian.getUShort(pptdata, i + 2);
+                // Record Size
+                final long recordSize = LittleEndian.getUInt(pptdata, i + 4);
+
+                if (recordType == PPTConstants.PPT_ATOM_DRAWINGGROUP) {
+                    /*
+                     * Record type is of Drawing Group
+                     */
+
+                    // Total number of objects
+                    // final long objectCount = LittleEndian.getUInt(pptdata,
+                    // (int) i +
+                    // 8);
+                    // currentID = Group ID+number of objects
+                    long currentID = LittleEndian.getInt(pptdata, i + 12);
+                    currentID = ((int) (currentID / 1024)) * 1024;
+
+                    if (currentID == PPTConstants.PPT_MASTERSLIDE) {
+                        // Ignore Master Slide objects
+                        if (LOG.isTraceEnabled()) {
+                            LOG.trace("Ignore master slide.");
+                        }
+                        i++;
+                        continue;
+                    }
+
+                    // Check for the ClientTextBox GroupID existence
+                    if (containerTextBox.containsKey(new Long(currentID))) {
+                        // If exists get Client Textbox Group
+                        textBox = (TextBox) containerTextBox.get(new Long(
+                                currentID));
+                        textBox.setContent("");
+
+                    } else {
+                        textBox = new TextBox(currentID);
+                        containerTextBox.put(new Long(currentID), textBox);
+                    }
+
+                    /*
+                     * Iterating the bytearray for TextCharAtoms and
+                     * TextBytesAtom
+                     */
+                    if ((offsetPD - 20) != recordSize) {
+                        // TODO something wrong? Probably an OLE-Object, which
+                        // we ignore.
+                        if (LOG.isDebugEnabled()) {
+                            LOG.debug("offsetPD - 20=" + (offsetPD - 20)
+                                    + " recordsize=" + recordSize);
+                        }
+                    } else {
+                        for (int startPos = i + 8; startPos < offsetPD - 20
+                                && startPos < recordSize; startPos++) { // &&
+                            // startPos
+                            // <
+                            // recordSize??
+                            try {
+
+                                // Record info
+                                // final long nrinfo =
+                                // LittleEndian.getUShort(pptdata, (int) j);
+
+                                // Record Type
+                                final long ntype = LittleEndian.getUShort(
+                                        pptdata, startPos + 2);
+
+                                // Record size
+                                // Note that the size doesn't include the 8 byte
+                                // atom header
+                                final long nsize = LittleEndian.getUInt(
+                                        pptdata, startPos + 4);
+
+                                if (ntype == PPTConstants.PPT_ATOM_DRAWINGGROUP) {
+                                    /*
+                                     * Break the loop if next GroupID found
+                                     */
+                                    i = startPos - 1;
+                                    break;
+                                } else if (ntype == PPTConstants.PPT_ATOM_TEXTBYTE) {
+                                    // TextByteAtom record
+                                    outStream = new FilteredStringWriter();
+                                    long ii = 0;
+                                    for (ii = startPos + 6; ii <= startPos + 6
+                                            + nsize; ii++) {
+                                        // For loop to changed to a function
+                                        // if ((ii + 2) >= pptdata.length)
+                                        // break; // FIXME
+                                        outStream
+                                                .write((char) (pptdata[(int) ii + 2]));
+                                    }
+
+                                    // Setting the identified text for Current
+                                    // groupID
+                                    textBox.setContent(textBox.getContent()
+                                            + outStream.toString());
+
+                                } else if (ntype == PPTConstants.PPT_ATOM_TEXTCHAR) {
+                                    // TextCharAtom record
+
+                                    final String strTempContent = new String(
+                                            pptdata, startPos + 6,
+                                            (int) (nsize) + 2);
+                                    final byte bytes[] = strTempContent
+                                            .getBytes();
+                                    if (true) {
+                                        outStream = new FilteredStringWriter();
+                                        for (int ii = 0; ii < bytes.length - 1; ii += 2) {
+                                            // For loop to changed to a function
+                                            outStream
+                                                    .write((char) (pptdata[ii + 2]));
+                                        }
+                                        textBox.setContent(textBox.getContent()
+                                                + outStream.toString());
+                                    } else {
+                                        // this version is used within POI
+                                        String text = StringUtil
+                                                .getFromCompressedUnicode(
+                                                        bytes, 0, bytes.length);
+                                        textBox.setContent(textBox.getContent()
+                                                + text);
+                                    }
+
+                                } else {
+                                    // ignored
+                                    // if (LOG.isTraceEnabled()) {
+                                    // LOG.trace("Ignored atom type: " + type);
+                                    // }
+                                }
+                            } catch (Throwable e) {
+
+                                LOG.error("extractTextBoxes", e);
+
+                                break;
+                            }
+                        }
+                    }
+                } else {
+                    // Record type is ignored
+                    // if (LOG.isTraceEnabled()) {
+                    // LOG.trace("Ignored record type: " + type);
+                    // }
+                }
+            } catch (Throwable ee) {
+
+                LOG.error("extractClientTextBoxes", ee);
+
+                break;
+            }
+        }
+        return containerTextBox;
+    }
+
+    /**
+     * Returns the Powerpoint <code>Slide</code> s of document as vector.
+     * 
+     * @param offset
+     * @param pptdata
+     * @param offsetPD
+     * @return Vector of the powerpoint slides. Contains
+     *         <code>{@link Slide Slide}</code>
+     * @see Slide
+     */
+    protected List /* <Slide> */extractSlides(final long offset,
+            final byte[] pptdata, final long offsetPD) {
+
+        int sNum = 0;
+
+        // List of all slides found
+        final List/* <Slide> */slides = new Vector/* <Slide> */();
+
+        // current slide data
+        Slide currentSlide = null;
+
+        // To store data found in TextCharAtoms and TextBytesAtoms
+        FilteredStringWriter outStream;
+
+        for (long i = offset; i < pptdata.length - 20; i++) {
+
+            final long recordInfo = LittleEndian.getUShort(pptdata, (int) i);
+            final long atomType = LittleEndian.getUShort(pptdata, (int) i + 2);
+            final long atomSize = LittleEndian.getUInt(pptdata, (int) i + 4);
+
+            if (atomType == PPTConstants.PPT_ATOM_TEXTBYTE) {
+                /*
+                 * TextByteAtom record
+                 */
+                outStream = new FilteredStringWriter();
+
+                for (long ii = i + 6; (ii <= i + 6 + atomSize)
+                        && (ii + 2 < pptdata.length); ii++) {
+                    try {
+                        // if(ii+2 >= pptdata.length) break; //FIXME
+                        byte value = pptdata[(int) ii + 2];
+                        outStream.write(value);
+                    } catch (ArrayIndexOutOfBoundsException ex) {
+                        if (LOG.isTraceEnabled()) {
+                            LOG.trace("size=" + pptdata.length);
+                        }
+
+                        LOG.error("extractSlides", ex);
+
+                    }
+                }
+
+                // Setting the identified text for Current Slide
+                if (currentSlide != null) {
+                    currentSlide.addContent(outStream.toString());
+                }
+
+            } else if (atomType == PPTConstants.PPT_ATOM_TEXTCHAR) {
+                /*
+                 * TextCharAtom record
+                 */
+                outStream = new FilteredStringWriter();
+                final String strTempContent = new String(pptdata, (int) i + 6,
+                        (int) (atomSize) + 2);
+                final byte bytes[] = strTempContent.getBytes();
+
+                for (int ii = 0; ii < bytes.length - 1; ii += 2) {
+                    outStream.write(Utils.getUnicodeCharacter(bytes, ii));
+                }
+
+                // Setting the identified text for Current Slide
+                if (currentSlide != null) {
+                    currentSlide.addContent(outStream.toString());
+                }
+
+            } else if (atomType == PPTConstants.PPT_ATOM_SLIDEPERSISTANT) {
+                /*
+                 * SlidePresistAtom Record
+                 */
+                if (sNum != 0) {
+                    outStream = new FilteredStringWriter();
+
+                    final long slideID = LittleEndian.getUInt(pptdata,
+                            (int) i + 20);
+
+                    currentSlide = new Slide(slideID);
+                    // currentSlide.addContent(outStream.toString());
+                    slides.add(currentSlide);
+                }
+                sNum++;
+            } else if (atomType == PPTConstants.PPT_ATOM_DRAWINGGROUP) {
+                /*
+                 * Diagram records are ignored
+                 */
+                if (LOG.isTraceEnabled()) {
+                    LOG.trace("Drawing Groups are ignored.");
+                }
+                break;
+            } else {
+                // ignored
+                // if (LOG.isTraceEnabled()) {
+                // LOG.trace("Unhandled atomType: " + atomType);
+                // }
+            }
+        }
+
+        return slides;
+    }
+}

Propchange: incubator/tika/trunk/src/main/java/org/apache/tika/parser/mspowerpoint/ContentReaderListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/tika/trunk/src/main/java/org/apache/tika/parser/mspowerpoint/FilteredStringWriter.java
URL: http://svn.apache.org/viewvc/incubator/tika/trunk/src/main/java/org/apache/tika/parser/mspowerpoint/FilteredStringWriter.java?view=auto&rev=567100
==============================================================================
--- incubator/tika/trunk/src/main/java/org/apache/tika/parser/mspowerpoint/FilteredStringWriter.java (added)
+++ incubator/tika/trunk/src/main/java/org/apache/tika/parser/mspowerpoint/FilteredStringWriter.java Fri Aug 17 11:17:06 2007
@@ -0,0 +1,70 @@
+/**
+ * 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.mspowerpoint;
+
+import java.io.StringWriter;
+
+/**
+ * Writes to optimize ASCII output. Not needed chars are filtered (ignored).
+ * 
+ * @author Stephan Strittmatter - http://www.sybit.de
+ * @version 1.0
+ */
+public class FilteredStringWriter extends StringWriter {
+
+  /**
+   * @see StringWriter#StringWriter()
+   */
+  public FilteredStringWriter() {
+    super();
+  }
+
+  /**
+   * @param initialSize
+   * @see StringWriter#StringWriter(int)
+   */
+  public FilteredStringWriter(final int initialSize) {
+    super(initialSize);
+  }
+
+  /**
+   * Chars which are not useful for Nutch indexing are filtered (ignored) on
+   * writing to the writer.
+   * 
+   * @see java.io.Writer#write(int)
+   */
+  public void write(final int ch) {
+    if (ch == '\r') {
+      // PowerPoint seems to store files with \r as the line break
+      // -> unify to platform specific format
+      super.write(System.getProperty("line.separator"));
+    } else if (ch == 0) {
+      super.write(System.getProperty("line.separator"));
+    } else if (ch == '\b') {
+      // ignore it
+    } else if (Character.isISOControl((char) ch)) {
+      // replace by blank
+      // super.write(' ');
+    } else if (Character.isWhitespace((char) ch)) {
+      // unify to blank
+      super.write(' ');
+    } else {
+      super.write(ch);
+    }
+  }
+}

Propchange: incubator/tika/trunk/src/main/java/org/apache/tika/parser/mspowerpoint/FilteredStringWriter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/tika/trunk/src/main/java/org/apache/tika/parser/mspowerpoint/MsPowerPointParser.java
URL: http://svn.apache.org/viewvc/incubator/tika/trunk/src/main/java/org/apache/tika/parser/mspowerpoint/MsPowerPointParser.java?view=auto&rev=567100
==============================================================================
--- incubator/tika/trunk/src/main/java/org/apache/tika/parser/mspowerpoint/MsPowerPointParser.java (added)
+++ incubator/tika/trunk/src/main/java/org/apache/tika/parser/mspowerpoint/MsPowerPointParser.java Fri Aug 17 11:17:06 2007
@@ -0,0 +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.mspowerpoint;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tika.config.Content;
+import org.apache.tika.parser.Parser;
+import org.apache.tika.utils.RegexUtils;
+
+import org.apache.log4j.Logger;
+import org.apache.oro.text.regex.MalformedPatternException;
+
+/**
+ * Power point parser
+ * 
+ * @author Rida Benjelloun (ridabenjelloun@apache.org)
+ */
+public class MsPowerPointParser extends Parser {
+
+    private PPTExtractor extrator = new PPTExtractor();
+
+    private String contentStr;
+
+    private Map<String, Content> contentsMap;
+
+    static Logger logger = Logger.getRootLogger();
+
+    public Content getContent(String name) {
+        if (contentsMap == null || contentsMap.isEmpty()) {
+            getContents();
+        }
+        return contentsMap.get(name);
+    }
+
+    public List<Content> getContents() {
+        if (contentStr == null) {
+            contentStr = getStrContent();
+        }
+        List<Content> ctt = getParserConfig().getContents();
+        contentsMap = new HashMap<String, Content>();
+        Iterator i = ctt.iterator();
+        while (i.hasNext()) {
+            Content ct = (Content) i.next();
+            if (ct.getTextSelect() != null) {
+                if (ct.getTextSelect().equalsIgnoreCase("fulltext")) {
+                    ct.setValue(contentStr);
+                }
+
+            } else if (ct.getRegexSelect() != null) {
+                try {
+                    List<String> valuesLs = RegexUtils.extract(contentStr, ct
+                            .getRegexSelect());
+                    if (valuesLs.size() > 0) {
+                        ct.setValue(valuesLs.get(0));
+                        ct.setValues(valuesLs.toArray(new String[0]));
+                    }
+                } catch (MalformedPatternException e) {
+                    logger.error(e.getMessage());
+                }
+            }
+            contentsMap.put(ct.getName(), ct);
+        }
+
+        return getParserConfig().getContents();
+
+    }
+
+    /*
+     * public List<Content> getContents() {
+     * extrator.setContents(getParserConfig().getContents()); try {
+     * extrator.extract(getInputStream()); } catch (Exception e) { // TODO
+     * Auto-generated catch block e.printStackTrace(); } return
+     * getParserConfig().getContents(); }
+     */
+
+    public String getStrContent() {
+        extrator.setContents(getParserConfig().getContents());
+        try {
+            contentStr = extrator.extractText(getInputStream());
+        } catch (Exception e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        return contentStr;
+    }
+
+}

Propchange: incubator/tika/trunk/src/main/java/org/apache/tika/parser/mspowerpoint/MsPowerPointParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/tika/trunk/src/main/java/org/apache/tika/parser/mspowerpoint/PPTConstants.java
URL: http://svn.apache.org/viewvc/incubator/tika/trunk/src/main/java/org/apache/tika/parser/mspowerpoint/PPTConstants.java?view=auto&rev=567100
==============================================================================
--- incubator/tika/trunk/src/main/java/org/apache/tika/parser/mspowerpoint/PPTConstants.java (added)
+++ incubator/tika/trunk/src/main/java/org/apache/tika/parser/mspowerpoint/PPTConstants.java Fri Aug 17 11:17:06 2007
@@ -0,0 +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.mspowerpoint;
+
+/**
+ * Package protected class for the required internal MS PowerPoint constants.
+ * 
+ * @author Stephan Strittmatter - http://www.sybit.de
+ * 
+ * @version 1.0
+ */
+class PPTConstants {
+
+  /** ID of master slide */
+  public static final long PPT_MASTERSLIDE = 1024L;
+
+  /** ATOM ID of slide */
+  public static long PPT_ATOM_SLIDE = 1007l;
+
+  /** ATOM ID of notes */
+  public static final long PPT_ATOM_NOTES = 1009L;
+
+  /** ATOM ID of persistend slide */
+  public static final long PPT_ATOM_SLIDEPERSISTANT = 1011L;
+
+  /** ATOM ID of text char area. Holds text in byte swapped unicode form. */
+  public static final long PPT_ATOM_TEXTCHAR = 4000L;
+
+  /** ATOM ID of text byte area. Holds text in ascii form */
+  public static final long PPT_ATOM_TEXTBYTE = 4008L;
+
+  /** ATOM ID of user edit area */
+  public static final long PPT_ATOM_USEREDIT = 4085L;
+
+  /** ATOM ID of drawing group area */
+  public static final long PPT_ATOM_DRAWINGGROUP = 61448L;
+
+  /** Name for PowerPoint Documents within the file */
+  public static final String POWERPOINT_DOCUMENT = "PowerPoint Document";
+
+
+
+  /**
+   * Protected constructor to prevent instantiation.
+   */
+  protected PPTConstants() {
+    // nothing
+  }
+}
\ No newline at end of file

Propchange: incubator/tika/trunk/src/main/java/org/apache/tika/parser/mspowerpoint/PPTConstants.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/tika/trunk/src/main/java/org/apache/tika/parser/mspowerpoint/PPTExtractor.java
URL: http://svn.apache.org/viewvc/incubator/tika/trunk/src/main/java/org/apache/tika/parser/mspowerpoint/PPTExtractor.java?view=auto&rev=567100
==============================================================================
--- incubator/tika/trunk/src/main/java/org/apache/tika/parser/mspowerpoint/PPTExtractor.java (added)
+++ incubator/tika/trunk/src/main/java/org/apache/tika/parser/mspowerpoint/PPTExtractor.java Fri Aug 17 11:17:06 2007
@@ -0,0 +1,56 @@
+/**
+ * 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.mspowerpoint;
+
+// JDK imports
+import java.io.InputStream;
+
+import org.apache.tika.utils.MSExtractor;
+
+import org.apache.log4j.Logger;
+import org.apache.poi.poifs.eventfilesystem.POIFSReader;
+
+/**
+ * Converts the Powerpoint document content to plain text.
+ * 
+ * @author Stephan Strittmatter - http://www.sybit.de
+ * @author J&eacute;r&ocirc;me Charron
+ */
+class PPTExtractor extends MSExtractor {
+
+    static Logger LOG = Logger.getRootLogger();
+
+    private StringBuffer text = null;
+
+    private POIFSReader reader = null;
+
+    public String extractText(InputStream input) throws Exception {
+        this.reader = new POIFSReader();
+        this.text = new StringBuffer();
+        reader.registerListener(new ContentReaderListener(this.text),
+                PPTConstants.POWERPOINT_DOCUMENT);
+        // input.reset();
+        if (input.available() > 0) {
+            this.reader.read(input);
+
+            LOG.warn("Input <=0 :" + input.available());
+
+        }
+        return (this.text != null) ? text.toString() : null;
+
+    }
+}

Propchange: incubator/tika/trunk/src/main/java/org/apache/tika/parser/mspowerpoint/PPTExtractor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/tika/trunk/src/main/java/org/apache/tika/parser/mspowerpoint/Slide.java
URL: http://svn.apache.org/viewvc/incubator/tika/trunk/src/main/java/org/apache/tika/parser/mspowerpoint/Slide.java?view=auto&rev=567100
==============================================================================
--- incubator/tika/trunk/src/main/java/org/apache/tika/parser/mspowerpoint/Slide.java (added)
+++ incubator/tika/trunk/src/main/java/org/apache/tika/parser/mspowerpoint/Slide.java Fri Aug 17 11:17:06 2007
@@ -0,0 +1,74 @@
+/**
+ * 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.mspowerpoint;
+
+import java.util.List;
+import java.util.Vector;
+
+/**
+ * Package protected class for a MS Powerpoint slide.
+ * 
+ * @author Stephan Strittmatter - http://www.sybit.de
+ * 
+ * @version 1.0
+ */
+class Slide {
+
+
+  /** Holds the Slide Number */
+  protected transient final long slideNumber;
+
+  /** Holds the contents of the Slide */
+  protected transient final List/* <String> */contents;
+
+  /**
+   * Initialise the Object for holding the contents of Power Point Slide
+   * 
+   * @param number
+   */
+  public Slide(long number) {
+    this.slideNumber = number;
+    this.contents = new Vector/* <String> */();
+  }
+
+  /**
+   * Add the Content of Slide to this Object
+   * 
+   * @param content
+   */
+  public void addContent(String content) {
+    this.contents.add(content);
+  }
+
+  /**
+   * returns the contents of slide as a vector object
+   * 
+   * @return Vector
+   */
+  public List getContent() {
+    return this.contents;
+  }
+
+  /**
+   * returns the slide value
+   * 
+   * @return long
+   */
+  public long getSlideNumber() {
+    return this.slideNumber;
+  }
+}
\ No newline at end of file

Propchange: incubator/tika/trunk/src/main/java/org/apache/tika/parser/mspowerpoint/Slide.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/tika/trunk/src/main/java/org/apache/tika/parser/mspowerpoint/TextBox.java
URL: http://svn.apache.org/viewvc/incubator/tika/trunk/src/main/java/org/apache/tika/parser/mspowerpoint/TextBox.java?view=auto&rev=567100
==============================================================================
--- incubator/tika/trunk/src/main/java/org/apache/tika/parser/mspowerpoint/TextBox.java (added)
+++ incubator/tika/trunk/src/main/java/org/apache/tika/parser/mspowerpoint/TextBox.java Fri Aug 17 11:17:06 2007
@@ -0,0 +1,89 @@
+/**
+ * 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.mspowerpoint;
+
+/**
+ * Package protected class for the MS Powerpoint TextBox content
+ * 
+ * @author Stephan Strittmatter - http://www.sybit.de
+ * 
+ * @version 1.0
+ */
+class TextBox {
+
+  /**
+   * Current id of a text box
+   */
+  protected transient final long currentID;
+
+  /**
+   * Content of text box
+   */
+  protected String content;
+
+  /**
+   * Instantiates the text box object
+   * 
+   * @param textBoxId
+   *          id of text box
+   */
+  public TextBox(final long textBoxId) {
+    this.currentID = textBoxId;
+    this.content = "";
+  }
+
+  /**
+   * Instantiates the text box object
+   * 
+   * @param textBoxId
+   *          id of text box
+   * @param content
+   *          content of text box
+   */
+  public TextBox(final long textBoxId, final String content) {
+    this.currentID = textBoxId;
+    this.content = content;
+  }
+
+  /**
+   * Sets the content of the text box
+   * 
+   * @param content
+   *          content of text Box
+   */
+  public void setContent(final String content) {
+    this.content = content;
+  }
+
+  /**
+   * Returns the content of the text box
+   * 
+   * @return content of text box
+   */
+  public String getContent() {
+    return this.content;
+  }
+
+  /**
+   * Returns the current text box id
+   * 
+   * @return long
+   */
+  public long getCurrentId() {
+    return this.currentID;
+  }
+}
\ No newline at end of file

Propchange: incubator/tika/trunk/src/main/java/org/apache/tika/parser/mspowerpoint/TextBox.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/tika/trunk/src/main/java/org/apache/tika/parser/msword/FastSavedException.java
URL: http://svn.apache.org/viewvc/incubator/tika/trunk/src/main/java/org/apache/tika/parser/msword/FastSavedException.java?view=auto&rev=567100
==============================================================================
--- incubator/tika/trunk/src/main/java/org/apache/tika/parser/msword/FastSavedException.java (added)
+++ incubator/tika/trunk/src/main/java/org/apache/tika/parser/msword/FastSavedException.java Fri Aug 17 11:17:06 2007
@@ -0,0 +1,24 @@
+/*  Copyright 2004 Ryan Ackley
+ *
+ *  Licensed 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.msword;
+
+
+public class FastSavedException extends Exception {
+  
+  public FastSavedException(String msg) {
+    super(msg);
+  }
+
+}

Propchange: incubator/tika/trunk/src/main/java/org/apache/tika/parser/msword/FastSavedException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/tika/trunk/src/main/java/org/apache/tika/parser/msword/MsWordParser.java
URL: http://svn.apache.org/viewvc/incubator/tika/trunk/src/main/java/org/apache/tika/parser/msword/MsWordParser.java?view=auto&rev=567100
==============================================================================
--- incubator/tika/trunk/src/main/java/org/apache/tika/parser/msword/MsWordParser.java (added)
+++ incubator/tika/trunk/src/main/java/org/apache/tika/parser/msword/MsWordParser.java Fri Aug 17 11:17:06 2007
@@ -0,0 +1,98 @@
+/**
+ * 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.msword;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tika.config.Content;
+import org.apache.tika.parser.Parser;
+import org.apache.tika.utils.MSExtractor;
+import org.apache.tika.utils.RegexUtils;
+
+import org.apache.log4j.Logger;
+import org.apache.oro.text.regex.MalformedPatternException;
+
+/**
+ * Word parser
+ * 
+ * @author Rida Benjelloun (ridabenjelloun@apache.org)
+ */
+public class MsWordParser extends Parser {
+
+    private MSExtractor extractor = new WordExtractor();
+
+    private String contentStr;
+
+    private Map<String, Content> contentsMap;
+
+    static Logger logger = Logger.getRootLogger();
+
+    public Content getContent(String name) {
+        if (contentsMap == null || contentsMap.isEmpty()) {
+            getContents();
+        }
+        return contentsMap.get(name);
+    }
+
+    public List<Content> getContents() {
+        if (contentStr == null) {
+            contentStr = getStrContent();
+        }
+        List<Content> ctt = getParserConfig().getContents();
+        contentsMap = new HashMap<String, Content>();
+        Iterator i = ctt.iterator();
+        while (i.hasNext()) {
+            Content ct = (Content) i.next();
+            if (ct.getTextSelect() != null) {
+                if (ct.getTextSelect().equalsIgnoreCase("fulltext")) {
+                    ct.setValue(contentStr);
+                }
+
+            } else if (ct.getRegexSelect() != null) {
+                try {
+                    List<String> valuesLs = RegexUtils.extract(contentStr, ct
+                            .getRegexSelect());
+                    if (valuesLs.size() > 0) {
+                        ct.setValue(valuesLs.get(0));
+                        ct.setValues(valuesLs.toArray(new String[0]));
+                    }
+                } catch (MalformedPatternException e) {
+                    logger.error(e.getMessage());
+                }
+            }
+            contentsMap.put(ct.getName(), ct);
+        }
+
+        return getParserConfig().getContents();
+
+    }
+
+    public String getStrContent() {
+        // extractor
+        try {
+            contentStr = extractor.extractText(getInputStream());
+        } catch (Exception e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        return contentStr;
+    }
+
+}

Propchange: incubator/tika/trunk/src/main/java/org/apache/tika/parser/msword/MsWordParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/tika/trunk/src/main/java/org/apache/tika/parser/msword/PasswordProtectedException.java
URL: http://svn.apache.org/viewvc/incubator/tika/trunk/src/main/java/org/apache/tika/parser/msword/PasswordProtectedException.java?view=auto&rev=567100
==============================================================================
--- incubator/tika/trunk/src/main/java/org/apache/tika/parser/msword/PasswordProtectedException.java (added)
+++ incubator/tika/trunk/src/main/java/org/apache/tika/parser/msword/PasswordProtectedException.java Fri Aug 17 11:17:06 2007
@@ -0,0 +1,24 @@
+/*  Copyright 2004 Ryan Ackley
+ *
+ *  Licensed 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.msword;
+
+
+public class PasswordProtectedException extends Exception {
+
+  public PasswordProtectedException(String msg) {
+    super(msg);
+  }
+
+}

Propchange: incubator/tika/trunk/src/main/java/org/apache/tika/parser/msword/PasswordProtectedException.java
------------------------------------------------------------------------------
    svn:eol-style = native