1 17 package org.apache.ws.jaxme.generator.sg.impl; 18 19 import java.util.ArrayList ; 20 import java.util.List ; 21 22 import org.apache.ws.jaxme.generator.sg.AtomicTypeSG; 23 import org.apache.ws.jaxme.generator.sg.Facet; 24 import org.apache.ws.jaxme.generator.sg.SimpleTypeSG; 25 import org.apache.ws.jaxme.generator.sg.SimpleTypeSGChain; 26 import org.apache.ws.jaxme.xs.XSEnumeration; 27 import org.apache.ws.jaxme.xs.XSSimpleType; 28 import org.apache.ws.jaxme.xs.XSType; 29 import org.xml.sax.SAXException ; 30 31 32 35 public class SimpleTypeRestrictionSG extends SimpleTypeSGChainImpl { 36 private XSSimpleType simpleType; 37 private XSType xsType; 38 private Facet[] facets; 39 private final AtomicTypeSG atomicTypeSG; 40 41 43 public SimpleTypeRestrictionSG(SimpleTypeSGChain o, XSType pType, XSSimpleType pSimpleType) { 44 super(o); 45 simpleType = pSimpleType; 46 if (pSimpleType.isAtomic()) { 47 atomicTypeSG = new AtomicTypeSGImpl(pSimpleType.getAtomicType()); 48 } else { 49 atomicTypeSG = null; 50 } 51 } 52 53 public void init(SimpleTypeSG pController) throws SAXException { 54 super.init(pController); 55 List myFacets = new ArrayList (); 56 57 XSEnumeration[] enumerations = simpleType.getEnumerations(); 58 if (enumerations.length > 0) { 59 Facet f = new FacetImpl(xsType, enumerations); 60 myFacets.add(f); 61 } 62 63 simpleType = null; xsType = null; facets = (Facet[]) myFacets.toArray(new Facet[myFacets.size()]); 66 } 67 68 public Facet[] getFacets(SimpleTypeSG pController) { 69 return facets; 70 } 71 72 public AtomicTypeSG getAtomicType(SimpleTypeSG pController) { 73 if (atomicTypeSG == null) { 74 return super.getAtomicType(pController); 75 } else { 76 return atomicTypeSG; 77 } 78 } 79 } 80 | Popular Tags |