summaryrefslogtreecommitdiff
path: root/ooxml/source/framework/JavaPartManager/src/org/apache/openoffice/ooxml/framework/part/parser/ParserFactory.java
blob: 83a635ca4077c3912752cbad76ef697f50c90ea5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package org.apache.openoffice.ooxml.framework.part.parser;

import java.io.File;
import java.io.InputStream;
import java.util.Vector;

import org.apache.openoffice.ooxml.framework.part.ContentType;
import org.apache.openoffice.ooxml.parser.Parser;
import org.apache.openoffice.ooxml.parser.StateMachine;

public class ParserFactory
{
    public static Parser getParser (
        final ContentType eType,
        final InputStream aStream,
        final Vector<String> aErrorsAndWarnings)
    {
        switch(eType)
        {
            case Relationships:
                return new RelationshipParser(aStream, msParserTableFilename, aErrorsAndWarnings);

            case ContentTypes:
                return new ContentTypesParser(aStream, msParserTableFilename, aErrorsAndWarnings);

            default:
                return new Parser(
                    new StateMachine(new File(msParserTableFilename), aErrorsAndWarnings),
                    aStream);
        }
    }




    public static void SetParserTableFilename (final String sFilename)
    {
        assert(new File(sFilename).exists());
        msParserTableFilename = sFilename;
    }




    private static String msParserTableFilename = null;
}