1 19 package org.enhydra.zeus.transform; 20 21 import java.util.LinkedList ; 22 import java.util.List ; 23 24 36 public class ValueEnumeration { 37 38 39 private String name; 40 41 42 private List allowedValues; 43 44 51 public ValueEnumeration(String name) { 52 this(name, new LinkedList ()); 53 } 54 55 64 public ValueEnumeration(String name, List allowedValues) { 65 if (name == null) { 67 throw new IllegalArgumentException ("A ValueEnumeration cannot " + 68 "have a null name."); 69 } 70 71 this.name = name; 72 this.allowedValues = allowedValues; 73 } 74 75 82 public void setName(String name) { 83 if (name == null) { 84 throw new IllegalArgumentException ("A ValueEnumeration cannot " + 85 "have a null name."); 86 } 87 this.name = name; 88 } 89 90 97 public String getName() { 98 return name; 99 } 100 101 110 public void setAllowedValues(List allowedValues) { 111 this.allowedValues = allowedValues; 112 } 113 114 121 public List getAllowedValues() { 122 return allowedValues; 123 } 124 125 132 public void addAllowedValue(String allowedValue) { 133 if (allowedValue == null) { 134 throw new IllegalArgumentException ("A ValueEnumeration cannot " + 135 "have the null value in its set of allowed values. To allow " + 136 "a variable to have the null value, use the String \"null\"."); 137 } 138 allowedValues.add(allowedValue); 139 } 140 141 148 public void removeAllowedValue(String removedValue) { 149 allowedValues.remove(removedValue); 150 } 151 152 165 public boolean isAllowedValue(String value) { 166 return allowedValues.contains(value); 167 } 168 } 169 | Popular Tags |