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.XSListType; 21 import org.apache.ws.jaxme.xs.XSType; 22 import org.apache.ws.jaxme.xs.parser.impl.LocSAXException; 23 import org.apache.ws.jaxme.xs.xml.XsEList; 24 import org.apache.ws.jaxme.xs.xml.XsQName; 25 import org.apache.ws.jaxme.xs.xml.XsTLocalSimpleType; 26 import org.xml.sax.SAXException ; 27 28 31 public class XSListTypeImpl extends XSSimpleTypeImpl implements XSListType { 32 private static final String [][] ZERO_PATTERNS = new String [0][]; 33 private static final XSEnumeration[] ZERO_ENUMERATIONS = new XSEnumeration[0]; 34 private final XSType itemType; 35 36 public boolean isRestriction() { return false; } 37 public XSType getRestrictedType() { 38 throw new IllegalStateException ("This is a basic list type and not a restriction of another simple type."); 39 } 40 41 public XSListTypeImpl(XSType pOwner, XsEList pBaseList) throws SAXException { 42 XsQName itemTypeName = pBaseList.getItemType(); 43 if (itemTypeName == null) { 44 XsTLocalSimpleType simpleType = pBaseList.getSimpleType(); 45 if (simpleType == null) { 46 throw new LocSAXException("You must either set the 'itemType' attribute or add a 'simpleType' element.", 47 pBaseList.getLocator()); 48 } 49 XSType type = pOwner.getXSSchema().getXSObjectFactory().newXSType(pOwner, simpleType); 50 type.validate(); 51 itemType = type; 52 } else { 53 XSType type = pOwner.getXSSchema().getType(itemTypeName); 54 if (type == null) { 55 throw new LocSAXException("Unknown item type: " + itemTypeName, pBaseList.getLocator()); 56 } 57 type.validate(); 58 if (!type.isSimple()) { 59 throw new LocSAXException("The item type " + itemTypeName + " is complex.", 60 pBaseList.getLocator()); 61 } 62 itemType = type; 63 } 64 } 65 66 public boolean isList() { return true; } 67 public XSListType getListType() { return this; } 68 public String [][] getPattern() { return ZERO_PATTERNS; } 69 public XSEnumeration[] getEnumerations() { return ZERO_ENUMERATIONS; } 70 public Long getLength() { return null; } 71 public Long getMinLength() { return null; } 72 public Long getMaxLength() { return null; } 73 public XSType getItemType() { return itemType; } 74 } 75 | Popular Tags |