Browse Source

fixed database view
fixed log

Mihai Plasoianu 10 years ago
parent
commit
9966c2aa39

+ 2 - 2
src/de/tudarmstadt/informatik/hostage/logging/formatter/DefaultFormatter.java

@@ -5,9 +5,9 @@ import de.tudarmstadt.informatik.hostage.logging.formatter.protocol.ProtocolForm
 
 public class DefaultFormatter extends Formatter {
 
-	private static DefaultFormatter INSTANCE = new DefaultFormatter();
+	private static Formatter INSTANCE = new DefaultFormatter();
 
-	public static DefaultFormatter getInstance() {
+	public static Formatter getInstance() {
 		return INSTANCE;
 	}
 

+ 2 - 2
src/de/tudarmstadt/informatik/hostage/logging/formatter/TraCINgFormatter.java

@@ -4,9 +4,9 @@ import de.tudarmstadt.informatik.hostage.logging.Record;
 
 public class TraCINgFormatter extends Formatter {
 
-	private static TraCINgFormatter INSTANCE = new TraCINgFormatter();
+	private static Formatter INSTANCE = new TraCINgFormatter();
 
-	public static TraCINgFormatter getInstance() {
+	public static Formatter getInstance() {
 		return INSTANCE;
 	}
 

+ 7 - 3
src/de/tudarmstadt/informatik/hostage/logging/formatter/protocol/ProtocolFormatter.java

@@ -22,12 +22,16 @@ public class ProtocolFormatter {
 	public static ProtocolFormatter getFormatter(String protocolName) {
 		String packageName = ProtocolFormatter.class.getPackage().getName();
 		String className = String.format("%s.%s", packageName, protocolName);
-		// TODO Auf Singletons umstellen und newInstance() sparen.
 		try {
 			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();
 		}
+
 	}
 
 	/**
@@ -39,7 +43,7 @@ public class ProtocolFormatter {
 	 * @return Formatted string.
 	 */
 	public String format(String packet) {
-		return packet;
+		return String.format("%s\n", packet);
 	}
 
 }

+ 2 - 1
src/de/tudarmstadt/informatik/hostage/wrapper/Packet.java

@@ -43,7 +43,8 @@ public class Packet {
 	 * 
 	 * @return String representation.
 	 */
-	public String getString() {
+	@Override
+	public String toString() {
 		StringBuilder builder = new StringBuilder(payload.length);
 		for (int i = 0; i < payload.length; ++i) {
 			if (payload[i] < 32) {