1 17 package org.apache.ws.jaxme.xs.impl; 18 19 import org.apache.ws.jaxme.xs.XSEnumeration; 20 import org.apache.ws.jaxme.xs.XSSimpleType; 21 import org.apache.ws.jaxme.xs.XSType; 22 import org.apache.ws.jaxme.xs.xml.XsEEnumeration; 23 import org.apache.ws.jaxme.xs.xml.XsEPattern; 24 import org.apache.ws.jaxme.xs.xml.XsGSimpleRestrictionModel; 25 import org.xml.sax.SAXException ; 26 27 30 public abstract class XSSimpleTypeRestrictionImpl extends XSSimpleTypeImpl { 31 private final XSSimpleType baseType; 32 private final XSType restrictedType; 33 private final XsGSimpleRestrictionModel restriction; 34 private final XSEnumeration[] enumerations; 35 36 protected XSSimpleTypeRestrictionImpl(XSType pParent, 37 XSType pRestrictedType, 38 XsGSimpleRestrictionModel pRestriction) 39 throws SAXException { 40 restrictedType = pRestrictedType; 41 baseType = pRestrictedType.getSimpleType(); 42 restriction = pRestriction; 43 44 XsEEnumeration[] enums = restriction.getEnumerations(); 45 if (enums.length == 0) { 46 enumerations = getBaseType().getEnumerations(); 47 } else { 48 enumerations = new XSEnumeration[enums.length]; 49 for (int i = 0; i < enums.length; i++) { 50 enumerations[i] = pParent.getXSSchema().getXSObjectFactory().newXSEnumeration(pParent, enums[i]); 51 } 52 } 53 } 54 55 protected XSSimpleType getBaseType() { 56 return baseType; 57 } 58 59 public boolean isRestriction() { return true; } 60 public XSType getRestrictedType() { return restrictedType; } 61 62 protected XsGSimpleRestrictionModel getRestriction() { 63 return restriction; 64 } 65 66 public String [][] getPattern() { 67 XsEPattern[] patterns = restriction.getPatterns(); 68 String [][] base = getBaseType().getPattern(); 69 if (patterns.length == 0) { 70 return base; 71 } else { 72 String [][] result; 73 if (base == null) { 74 result = new String [1][]; 75 } else { 76 result = new String [base.length+1][]; 77 for (int i = 0; i < base.length; i++) { 78 result[i+1] = base[i]; 79 } 80 } 81 String [] thisStepsPatterns = new String [patterns.length]; 82 for (int i = 0; i < patterns.length; i++) { 83 thisStepsPatterns[i] = patterns[i].getValue(); 84 } 85 result[0] = thisStepsPatterns; 86 return result; 87 } 88 } 89 90 public XSEnumeration[] getEnumerations() { 91 return enumerations; 92 } 93 } 94 | Popular Tags |