1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 package org.apache.openoffice.ooxml.framework.part.parser; 23 24 import java.io.File; 25 import java.io.InputStream; 26 import java.util.Vector; 27 28 import org.apache.openoffice.ooxml.framework.part.ContentType; 29 import org.apache.openoffice.ooxml.parser.Parser; 30 import org.apache.openoffice.ooxml.parser.StateMachine; 31 32 public class ParserFactory 33 { getParser( final ContentType eType, final InputStream aStream, final Vector<String> aErrorsAndWarnings)34 public static Parser getParser ( 35 final ContentType eType, 36 final InputStream aStream, 37 final Vector<String> aErrorsAndWarnings) 38 { 39 switch(eType) 40 { 41 case Relationships: 42 return new RelationshipParser(aStream, msParserTableFilename, aErrorsAndWarnings); 43 44 case ContentTypes: 45 return new ContentTypesParser(aStream, msParserTableFilename, aErrorsAndWarnings); 46 47 default: 48 return new Parser( 49 new StateMachine(new File(msParserTableFilename), aErrorsAndWarnings), 50 aStream); 51 } 52 } 53 54 55 56 SetParserTableFilename(final String sFilename)57 public static void SetParserTableFilename (final String sFilename) 58 { 59 assert(new File(sFilename).exists()); 60 msParserTableFilename = sFilename; 61 } 62 63 64 65 66 private static String msParserTableFilename = null; 67 } 68