1 19 20 package org.netbeans.modules.xml.axi.datatype; 21 22 import java.util.ArrayList ; 23 import java.util.Collections ; 24 import java.util.List ; 25 import org.netbeans.modules.xml.axi.datatype.Datatype.Facet; 26 import org.netbeans.modules.xml.schema.model.Whitespace; 27 28 32 public abstract class BinaryBase extends Datatype { 33 34 static List <Facet> applicableFacets; 35 36 private Datatype.Kind kind; 37 38 protected boolean hasFacets; 39 40 private boolean isList; 41 42 private List <Integer > lengths; 43 44 private List <Integer > minLengths; 45 46 private List <Integer > maxLengths; 47 48 private List <String > patterns; 49 50 protected List <String > enumerations; 51 52 private List <Whitespace.Treatment> whitespaces; 53 54 55 56 public BinaryBase(Kind kind) { 57 this.kind = kind; 58 } 59 60 public Kind getKind() { 61 return kind; 62 } 63 64 public synchronized List <Facet> getApplicableFacets() { 65 if(applicableFacets == null) { 66 List <Facet> facets = new ArrayList <Facet>(); 67 facets.add(Facet.LENGTH); 68 facets.add(Facet.MINLENGTH); 69 facets.add(Facet.MAXLENGTH); 70 facets.add(Facet.PATTERN); 71 facets.add(Facet.ENUMERATION); 72 facets.add(Facet.WHITESPACE); 73 applicableFacets = Collections.unmodifiableList(facets); 74 } 75 return applicableFacets; 76 } 77 78 public boolean hasFacets() { 79 return hasFacets; 80 } 81 82 public boolean isList() { 83 return isList; 84 } 85 86 public void setIsList(boolean isList) { 87 this.isList = isList; 88 } 89 90 95 public List <Integer > getLengths() { 96 return lengths; 97 } 98 99 104 public List <Integer > getMinLengths() { 105 return minLengths; 106 } 107 108 113 public List <Integer > getMaxLengths() { 114 return maxLengths; 115 } 116 117 122 public List <String > getPatterns() { 123 return patterns; 124 } 125 126 131 public List <String > getEnumerations() { 132 return enumerations; 133 } 134 135 140 public List <Whitespace.Treatment> getWhiteSpaces() { 141 return whitespaces; 142 } 143 144 149 public void addLength(int length) { 150 if(lengths == null) { 151 lengths = new ArrayList <Integer >(1); 152 hasFacets = true; 153 } 154 this.lengths.add(new Integer (length)); 155 } 156 157 162 public void addMinLength(int minLength) { 163 if(minLengths == null) { 164 minLengths = new ArrayList <Integer >(1); 165 hasFacets = true; 166 } 167 this.minLengths.add(new Integer (minLength)); 168 } 169 170 175 public void addMaxLength(int maxLength) { 176 if(maxLengths == null) { 177 maxLengths = new ArrayList <Integer >(1); 178 hasFacets = true; 179 } 180 this.maxLengths.add(new Integer (maxLength)); 181 } 182 183 188 public void addPattern(String pattern) { 189 if(patterns == null) { 190 patterns = new ArrayList <String >(1); 191 hasFacets = true; 192 } 193 this.patterns.add(pattern); 194 } 195 196 201 public void addEnumeration(String enumeration) { 202 if(enumerations == null) { 203 enumerations = new ArrayList <String >(1); 204 hasFacets = true; 205 } 206 this.enumerations.add(enumeration); 207 } 208 209 214 public void addWhitespace(Whitespace.Treatment whitespace) { 215 if(whitespaces == null) { 216 whitespaces = new ArrayList <Whitespace.Treatment>(1); 217 hasFacets = true; 218 } 219 this.whitespaces.add(whitespace); 220 } 221 222 227 public void removeLength(Number length) { 228 if(lengths != null) 229 lengths.remove(length); 230 } 231 232 237 public void removeMinLength(Number minLength) { 238 if(minLengths != null) 239 minLengths.remove(minLength); 240 } 241 242 247 public void removeMaxLength(Number maxLength) { 248 if(maxLengths != null) 249 maxLengths.remove(maxLength); 250 } 251 252 257 public void removePattern(String pattern) { 258 if(patterns != null) 259 patterns.remove(pattern); 260 } 261 262 267 public void removeEnumeration(String enumeration) { 268 if(enumerations != null) 269 enumerations.remove(enumeration); 270 } 271 272 277 public void removeWhitespace(Whitespace.Treatment whitespace) { 278 if(whitespaces != null) 279 whitespaces.remove(whitespace); 280 } 281 } 282 | Popular Tags |