package org.javarosa.core.log;

import org.javarosa.core.util.externalizable.DeserializationException;
import org.javarosa.core.util.externalizable.ExtUtil;
import org.javarosa.core.util.externalizable.Externalizable;
import org.javarosa.core.util.externalizable.PrototypeFactory;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Date;

/**
 * @author Clayton Sims
 */
public class LogEntry implements Externalizable {
    public static final String STORAGE_KEY = "LOG";

    private Date time;
    private String type;
    private String message;

    public LogEntry() {
        // for externalization
    }

    public LogEntry(String type, String message, Date time) {
        this.time = time;
        this.type = type;
        this.message = message;
    }

    public Date getTime() {
        return time;
    }

    public String getType() {
        return type;
    }

    public String getMessage() {
        return message;
    }

    @Override
    public void readExternal(DataInputStream in, PrototypeFactory pf)
            throws IOException, DeserializationException {
        time = ExtUtil.readDate(in);
        type = ExtUtil.readString(in);
        message = ExtUtil.readString(in);
    }

    @Override
    public void writeExternal(DataOutputStream out) throws IOException {
        ExtUtil.writeDate(out, time);
        ExtUtil.writeString(out, ExtUtil.emptyIfNull(type));
        ExtUtil.writeString(out, ExtUtil.emptyIfNull(message));
    }
}

@@ -533,21 +533,23 @@
 %0A%0A    pr
-ivate
+otected
  Date ti
@@ -550,37 +550,39 @@
 ate time;%0A    pr
-ivate
+otected
  String type;%0A  
@@ -589,13 +589,15 @@
   pr
-ivate
+otected
  Str

make AndroidLogEntry use super where appropriate