Tag implements Comparable<Tag>, Serializable { @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append("<"); builder.append(name); builder.append(" [").append(begin).append("-").append(end).append("]"); for (Entry<String, String> entry : attributes.entrySet()) { builder.append(' '); builder.append(entry.getKey()); builder.append('='); builder.append('"'); builder.append(entry.getValue()); builder.append('"'); } builder.append('>'); return builder.toString(); } Tag(String name, Map<String, String> attributes, int termBegin, int termEnd, int charBegin, int charEnd);  Tag(String name, Map<String, String> attributes, int termBegin, int termEnd); @Override int compareTo(Tag other); @Override String toString(); public String name; public Map<String, String> attributes; public int begin; public int end; public int charBegin; public int charEnd; }
@Test public void testToString() { Tag t = new Tag("a", Collections.singletonMap("b", "c"), 0, 1); assertEquals("<a [0-1] b=\"c\">", t.toString()); }