1 46 package org.codehaus.groovy.ast; 47 48 import java.util.ArrayList ; 49 import java.util.HashMap ; 50 import java.util.List ; 51 import java.util.Map ; 52 53 54 60 public class MetadataNode extends ASTNode { 61 private Map attributes = new HashMap (); 62 private boolean synthetic; 63 64 public Map getAttributes() { 65 return attributes; 66 } 67 68 public Object getAttributes(String name) { 69 return attributes.get(name); 70 } 71 72 public void addAttribute(String name, Object value) { 73 Object oldValue = attributes.get(name); 74 if (oldValue == null) { 75 attributes.put(name, value); 76 } 77 else { 78 List list = null; 79 if (oldValue instanceof List ) { 80 list = (List ) oldValue; 81 } 82 else { 83 list = new ArrayList (); 84 list.add(oldValue); 85 attributes.put(name, list); 86 } 87 list.add(value); 88 } 89 } 90 91 public void setAttribute(String name, Object value) { 92 attributes.put(name, value); 93 } 94 95 public boolean isSynthetic() { 96 return synthetic; 97 } 98 99 public void setSynthetic(boolean synthetic) { 100 this.synthetic = synthetic; 101 } 102 103 } 104 | Popular Tags |