You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
850 B
38 lines
850 B
10 years ago
|
package com.mykaruga.models.wavefront.loader;
|
||
|
|
||
|
|
||
|
import java.util.Hashtable;
|
||
|
|
||
|
import com.mykaruga.models.wavefront.parser.DefaultParser;
|
||
|
import com.mykaruga.models.wavefront.parser.LineParser;
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
public abstract class LineParserFactory {
|
||
|
|
||
|
protected Hashtable<String, LineParser> parsers = new Hashtable<String, LineParser>();
|
||
|
protected RenderModel object = null;
|
||
|
|
||
|
|
||
|
public LineParser getLineParser(String line) {
|
||
|
if (line == null) return null;
|
||
|
|
||
|
line = line.replaceAll(" ", " ");
|
||
|
line = line.replaceAll(" ", "");
|
||
|
String[] lineWords = line.split(" ");
|
||
|
|
||
|
if (lineWords.length < 1) return new DefaultParser();
|
||
|
|
||
|
String lineType = lineWords[0];
|
||
|
|
||
|
LineParser parser = parsers.get(lineType);
|
||
|
if (parser == null) {
|
||
|
parser = new DefaultParser();
|
||
|
}
|
||
|
|
||
|
parser.setWords(lineWords);
|
||
|
return parser;
|
||
|
}
|
||
|
}
|