01: package org.objectweb.celtix.tools.common.model;
02:
03: import java.util.*;
04:
05: public class JavaAnnotation {
06: private static final String DEFAULT_QUOTE = "\"";
07:
08: private String tagName;
09: private final Map<String, String> arguments = new HashMap<String, String>();
10:
11: public JavaAnnotation() {
12: }
13:
14: public JavaAnnotation(String tn) {
15: this .tagName = tn;
16: }
17:
18: public void addArgument(String key, String value, String quote) {
19: arguments.put(key, quote + value + quote);
20: }
21:
22: public void addArgument(String key, String value) {
23: addArgument(key, value, DEFAULT_QUOTE);
24: }
25:
26: public String toString() {
27: StringBuffer sb = new StringBuffer();
28: sb.append("@");
29: sb.append(this .tagName);
30: Object[] keys = arguments.keySet().toArray();
31: if (keys.length > 0) {
32: sb.append("(");
33: for (int i = 0; i < keys.length; i++) {
34: sb.append((String) keys[i]);
35: sb.append(" = ");
36: sb.append(this .arguments.get((String) keys[i]));
37: if (i != (keys.length - 1)) {
38: sb.append(", ");
39: }
40: }
41: sb.append(")");
42: }
43: return sb.toString();
44: }
45: }
|