1 19 package org.java.plugin.tools.mocks; 20 21 import java.util.Collection ; 22 import java.util.Collections ; 23 import java.util.Iterator ; 24 import java.util.LinkedList ; 25 26 import org.java.plugin.registry.PluginAttribute; 27 28 31 public class MockPluginAttribute extends MockPluginElement implements 32 PluginAttribute { 33 private LinkedList subAttributes = new LinkedList (); 34 private PluginAttribute superAttribute; 35 private String value; 36 37 40 public MockPluginAttribute() { 41 } 43 44 48 public MockPluginAttribute(final String id, final String aValue) { 49 setId(id); 50 value = aValue; 51 } 52 53 57 public PluginAttribute getSubAttribute(final String id) { 58 for (Iterator it = subAttributes.iterator(); it.hasNext();) { 59 PluginAttribute attr = (PluginAttribute) it.next(); 60 if (attr.getId().equals(id)) { 61 return attr; 62 } 63 } 64 throw new IllegalArgumentException ("unknown attribute ID " + id); } 66 67 70 public Collection getSubAttributes() { 71 return Collections.unmodifiableCollection(subAttributes); 72 } 73 74 78 public Collection getSubAttributes(final String id) { 79 LinkedList result = new LinkedList (); 80 for (Iterator it = subAttributes.iterator(); it.hasNext();) { 81 PluginAttribute attr = (PluginAttribute) it.next(); 82 if (attr.getId().equals(id)) { 83 result.add(attr); 84 } 85 } 86 return result; 87 } 88 89 93 public MockPluginAttribute addSubAttribute( 94 final PluginAttribute attribute) { 95 subAttributes.add(attribute); 96 return this; 97 } 98 99 102 public PluginAttribute getSuperAttribute() { 103 return superAttribute; 104 } 105 106 110 public MockPluginAttribute setSuperAttribute( 111 final PluginAttribute attribute) { 112 superAttribute = attribute; 113 return this; 114 } 115 116 119 public String getValue() { 120 return value; 121 } 122 123 127 public MockPluginAttribute setValue(final String attributeValue) { 128 value = attributeValue; 129 return this; 130 } 131 } 132 | Popular Tags |