Better diagnostic

This commit is contained in:
Knut Forkalsrud 2014-01-04 16:43:57 -08:00
parent afeae7861d
commit 87429b018c
2 changed files with 62 additions and 4 deletions

View file

@ -8,8 +8,6 @@ package org.forkalsrud.album.exif;
import java.io.File; import java.io.File;
import java.util.Date; import java.util.Date;
import org.apache.commons.lang.builder.ToStringBuilder;
/** /**
* Represents one item inside the album, typically file or directory, aka photo or album * Represents one item inside the album, typically file or directory, aka photo or album
@ -130,8 +128,59 @@ public abstract class Entry {
protected void appendDiagnostic(StringBuilder buf) {
buf.append("file: ");
appendFile(buf);
buf.append(",");
buf.append("thumbnail: ");
if (thumbnail != null) {
buf.append(thumbnail);
} else {
buf.append("null");
}
buf.append(",");
buf.append("caption: ");
if (caption != null) {
buf.append(caption);
} else {
buf.append("null");
}
buf.append(",");
buf.append("date: ");
buf.append(date);
buf.append(",");
buf.append("next: ");
if (next != null) {
next.appendFile(buf);
} else {
buf.append("null");
}
buf.append(",");
buf.append("prev: ");
if (prev != null) {
prev.appendFile(buf);
} else {
buf.append("null");
}
buf.append(",");
buf.append("type: ");
buf.append(type);
}
protected void appendFile(StringBuilder buf) {
if (file != null) {
buf.append(file.getAbsolutePath());
} else {
buf.append("null");
}
}
@Override @Override
public String toString() { public String toString() {
return ToStringBuilder.reflectionToString(this); StringBuilder buf = new StringBuilder("{");
appendDiagnostic(buf);
buf.append("}");
return buf.toString();
} }
} }

View file

@ -56,4 +56,13 @@ public class EntryWithChildren<T extends Entry> extends Entry {
} }
return null; return null;
} }
@Override
protected void appendDiagnostic(StringBuilder buf) {
super.appendDiagnostic(buf);
buf.append(",");
buf.append("children: list of ");
buf.append(children != null ? String.valueOf(children.size()) : "null");
}
} }