From 0f77dade102b39661c5b91ef88c21e0dcd84b649 Mon Sep 17 00:00:00 2001 From: Thorsten Vitt <thorsten.vitt@uni-wuerzburg.de> Date: Mon, 27 May 2013 12:00:34 +0000 Subject: [PATCH] toString methods for testing & debugging git-svn-id: https://develop.sub.uni-goettingen.de/repos/textgrid/trunk/services/aggregator@14092 7c539038-3410-0410-b1ec-0f2a7bf1c452 --- .../services/aggregator/tree/Aggregation.java | 6 ++++++ .../services/aggregator/tree/AggregationEntry.java | 14 ++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/main/java/info/textgrid/services/aggregator/tree/Aggregation.java b/src/main/java/info/textgrid/services/aggregator/tree/Aggregation.java index e98181d..153f072 100644 --- a/src/main/java/info/textgrid/services/aggregator/tree/Aggregation.java +++ b/src/main/java/info/textgrid/services/aggregator/tree/Aggregation.java @@ -4,6 +4,7 @@ import java.util.List; +import com.google.common.base.Joiner; import com.google.common.collect.Lists; public class Aggregation extends AggregationEntry { @@ -18,6 +19,11 @@ public Aggregation(final ObjectType metadata, final Aggregation parent) { super(metadata, parent); } + @Override + public String toString() { + return super.toString() + ": [" + Joiner.on(", ").join(children) + "]"; + } + protected Aggregation add(final AggregationEntry child) { children.add(child); return this; diff --git a/src/main/java/info/textgrid/services/aggregator/tree/AggregationEntry.java b/src/main/java/info/textgrid/services/aggregator/tree/AggregationEntry.java index 7bfcc7a..de4f008 100644 --- a/src/main/java/info/textgrid/services/aggregator/tree/AggregationEntry.java +++ b/src/main/java/info/textgrid/services/aggregator/tree/AggregationEntry.java @@ -2,6 +2,8 @@ import info.textgrid.namespaces.metadata.core._2010.ObjectType; +import java.text.MessageFormat; + import com.google.common.collect.ImmutableList; public class AggregationEntry { @@ -27,4 +29,16 @@ public ObjectType getMetadata() { return metadata; } + @Override + public String toString() { + try { + return MessageFormat.format("{0} ({1}, {2})", metadata.getGeneric() + .getGenerated().getTextgridUri().getValue(), metadata + .getGeneric().getProvided().getTitle().get(0), metadata + .getGeneric().getProvided().getFormat()); + } catch (final NullPointerException e) { + return ("<AggregationEntry w/o complete metadata>"); + } + } + } -- GitLab