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 class StringBase extends Datatype { 33 34 static List <Facet> applicableFacets; 35 36 private Datatype.Kind kind; 37 38 private String name; 39 40 private boolean hasFacets; 41 42 private boolean isList; 43 44 private List <Integer > lengths; 45 46 private List <Integer > minLengths; 47 48 private List <Integer > maxLengths; 49 50 private List <String > patterns; 51 52 private List <String > enumerations; 53 54 private List <Whitespace.Treatment> whitespaces; 55 56 57 public StringBase(Kind kind) { 58 this.kind = kind; 59 } 60 61 public Kind getKind() { 62 return kind; 63 } 64 65 public synchronized List <Facet> getApplicableFacets() { 66 if(applicableFacets == null) { 67 List <Facet> facets = new ArrayList <Facet>(); 68 facets.add(Facet.LENGTH); 69 facets.add(Facet.MINLENGTH); 70 facets.add(Facet.MAXLENGTH); 71 facets.add(Facet.PATTERN); 72 facets.add(Facet.ENUMERATION); 73 facets.add(Facet.WHITESPACE); 74 applicableFacets = Collections.unmodifiableList(facets); 75 } 76 return applicableFacets; 77 } 78 79 public boolean hasFacets() { 80 return hasFacets; 81 } 82 83 public boolean isList() { 84 return isList; 85 } 86 87 public void setIsList(boolean isList) { 88 this.isList = isList; 89 } 90 91 96 public List <Integer > getLengths() { 97 return lengths; 98 } 99 100 105 public List <Integer > getMinLengths() { 106 return minLengths; 107 } 108 109 114 public List <Integer > getMaxLengths() { 115 return maxLengths; 116 } 117 118 123 public List <String > getPatterns() { 124 return patterns; 125 } 126 127 132 public List <String > getEnumerations() { 133 return enumerations; 134 } 135 136 141 public List <Whitespace.Treatment> getWhiteSpaces() { 142 return whitespaces; 143 } 144 145 150 public void addLength(int length) { 151 if(lengths == null) { 152 lengths = new ArrayList <Integer >(1); 153 hasFacets = true; 154 } 155 this.lengths.add(new Integer (length)); 156 } 157 158 163 public void addMinLength(int minLength) { 164 if(minLengths == null) { 165 minLengths = new ArrayList <Integer >(1); 166 hasFacets = true; 167 } 168 this.minLengths.add(new Integer (minLength)); 169 } 170 171 176 public void addMaxLength(int maxLength) { 177 if(maxLengths == null) { 178 maxLengths = new ArrayList <Integer >(1); 179 hasFacets = true; 180 } 181 this.maxLengths.add(new Integer (maxLength)); 182 } 183 184 189 public void addPattern(String pattern) { 190 if(patterns == null) { 191 patterns = new ArrayList <String >(1); 192 hasFacets = true; 193 } 194 this.patterns.add(pattern); 195 } 196 197 202 public void addEnumeration(String enumeration) { 203 if(enumerations == null) { 204 enumerations = new ArrayList <String >(1); 205 hasFacets = true; 206 } 207 this.enumerations.add(enumeration); 208 } 209 210 215 public void addWhitespace(Whitespace.Treatment whitespace) { 216 if(whitespaces == null) { 217 whitespaces = new ArrayList <Whitespace.Treatment>(1); 218 hasFacets = true; 219 } 220 this.whitespaces.add(whitespace); 221 } 222 223 228 public void removeLength(Number length) { 229 if(lengths != null) 230 lengths.remove(length); 231 } 232 233 238 public void removeMinLength(Number minLength) { 239 if(minLengths != null) 240 minLengths.remove(minLength); 241 } 242 243 248 public void removeMaxLength(Number maxLength) { 249 if(maxLengths != null) 250 maxLengths.remove(maxLength); 251 } 252 253 258 public void removePattern(String pattern) { 259 if(patterns != null) 260 patterns.remove(pattern); 261 } 262 263 268 public void removeEnumeration(String enumeration) { 269 if(enumerations != null) 270 enumerations.remove(enumeration); 271 } 272 273 278 public void removeWhitespace(Whitespace.Treatment whitespace) { 279 if(whitespaces != null) 280 whitespaces.remove(whitespace); 281 } 282 } 283 | Popular Tags |