1 19 20 package org.netbeans.modules.xml.schema.model.impl; 21 import org.netbeans.modules.xml.schema.model.SchemaComponent; 22 import org.netbeans.modules.xml.schema.model.TotalDigits; 23 import org.netbeans.modules.xml.schema.model.visitor.SchemaVisitor; 24 import org.w3c.dom.Element ; 25 26 37 public class TotalDigitsImpl extends CommonLength implements TotalDigits { 38 39 public TotalDigitsImpl(SchemaModelImpl model) { 40 this(model, createNewComponent(SchemaElements.TOTAL_DIGITS,model)); 41 } 42 43 44 public TotalDigitsImpl(SchemaModelImpl model, Element e) { 45 super(model, e); 46 } 47 48 52 public Class <? extends SchemaComponent> getComponentType() { 53 return TotalDigits.class; 54 } 55 56 public void accept(SchemaVisitor visitor) { 57 visitor.visit(this); 58 } 59 60 public String getComponentName() { 61 return SchemaElements.TOTAL_DIGITS.toString(); 62 } 63 64 @Override 65 public void setValue(int v) { 66 if (v < 1) { 67 throw new IllegalArgumentException ("Element 'totalDigits' can only have positive integer value."); 68 } 69 setAttribute(VALUE_PROPERTY, SchemaAttributes.VALUE, Integer.valueOf(v)); 70 } 71 72 @Override 73 public int getValue() { 74 String v = getAttribute(SchemaAttributes.VALUE); 75 if (v == null) { 76 return 1; 77 } 78 int i = Integer.valueOf(v); 79 if (i < 1) { 80 throw new IllegalArgumentException ("Element '" + SchemaElements.TOTAL_DIGITS + "' got non-positive integer value."); 81 } 82 return i; 83 } 84 85 } 86 | Popular Tags |