View Javadoc

1   package net.sourceforge.argval.message.impl;
2   
3   
4   import net.sourceforge.argval.lang.SystemConstants;
5   import net.sourceforge.argval.message.MessageItem;
6   import net.sourceforge.argval.message.MessageStore;
7   import net.sourceforge.argval.message.MessageStoreVisitor;
8   
9   
10  public class TextMessageStoreVisitorImpl implements MessageStoreVisitor {
11  	private static final String NL = System.getProperty(SystemConstants.LINE_SEPARATOR);
12      private StringBuilder builder;
13  	
14  	
15  	public TextMessageStoreVisitorImpl() {
16  		this(new StringBuilder());
17  	}
18  
19  	public TextMessageStoreVisitorImpl(StringBuilder builder) {
20  		super();
21  		this.builder = builder;
22  	}
23  
24  	
25  	public void visit(MessageStore messageStore) {
26  		// Nothing to do here.
27  	}
28  
29  	
30  	public void visit(MessageItem messageItem) {
31  		builder.append(messageItem.getDate())
32  				.append(" ").append(messageItem.getPriority().toUpperCase())
33  				.append("  ").append(messageItem.getMessage()).append(NL);
34  	}
35  	
36  	
37  	public String getAsText() {
38  		return builder.toString();
39  	}
40  
41  }