|
@@ -22,12 +22,16 @@ public class ProtocolFormatter {
|
|
public static ProtocolFormatter getFormatter(String protocolName) {
|
|
public static ProtocolFormatter getFormatter(String protocolName) {
|
|
String packageName = ProtocolFormatter.class.getPackage().getName();
|
|
String packageName = ProtocolFormatter.class.getPackage().getName();
|
|
String className = String.format("%s.%s", packageName, protocolName);
|
|
String className = String.format("%s.%s", packageName, protocolName);
|
|
- // TODO Auf Singletons umstellen und newInstance() sparen.
|
|
|
|
try {
|
|
try {
|
|
return (ProtocolFormatter) Class.forName(className).newInstance();
|
|
return (ProtocolFormatter) Class.forName(className).newInstance();
|
|
- } catch (ReflectiveOperationException e) {
|
|
|
|
|
|
+ } catch (InstantiationException e) {
|
|
|
|
+ return new ProtocolFormatter();
|
|
|
|
+ } catch (IllegalAccessException e) {
|
|
|
|
+ return new ProtocolFormatter();
|
|
|
|
+ } catch (ClassNotFoundException e) {
|
|
return new ProtocolFormatter();
|
|
return new ProtocolFormatter();
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -39,7 +43,7 @@ public class ProtocolFormatter {
|
|
* @return Formatted string.
|
|
* @return Formatted string.
|
|
*/
|
|
*/
|
|
public String format(String packet) {
|
|
public String format(String packet) {
|
|
- return packet;
|
|
|
|
|
|
+ return String.format("%s\n", packet);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|