Factory method to create a parser engine.
constructorArgs = new Class[1];
constructorArgs[0] = new String().getClass();
parserTable = new Hashtable();
parserTable.put("a", getParser("AttributeFieldParser"));
parserTable.put("b", getParser("BandwidthFieldParser"));
parserTable.put("c", getParser("ConnectionFieldParser"));
parserTable.put("e", getParser("EmailFieldParser"));
parserTable.put("i", getParser("InformationFieldParser"));
parserTable.put("k", getParser("KeyFieldParser"));
parserTable.put("m", getParser("MediaFieldParser"));
parserTable.put("o", getParser("OriginFieldParser"));
parserTable.put("p", getParser("PhoneFieldParser"));
parserTable.put("v", getParser("ProtoVersionFieldParser"));
parserTable.put("r", getParser("RepeatFieldParser"));
parserTable.put("s", getParser("SessionNameFieldParser"));
parserTable.put("t", getParser("TimeFieldParser"));
parserTable.put("u", getParser("URIFieldParser"));
parserTable.put("z", getParser("ZoneFieldParser"));
String fieldName = Lexer.getFieldName(field);
if (fieldName == null)
return null;
Class parserClass =
(Class) parserTable.get(fieldName.toLowerCase());
if (parserClass != null) {
Exception ex = null;
try {
SDPParser retval = (SDPParser) parserClass.newInstance();
retval.setField(field);
return retval;
} catch (InstantiationException ie) {
ex = ie;
} catch (IllegalAccessException iae) {
ex = iae;
}
if (ex != null) {
// print system message and exit
InternalErrorHandler.handleException(ex);
return null;
}
} else
throw new ParseException
("Could not find parser for " + fieldName, 0);