1 package org.apache.ws.jaxme.generator.sg.impl.ccsg; 2 3 import org.apache.ws.jaxme.generator.sg.GroupSG; 4 import org.apache.ws.jaxme.generator.sg.ParticleSG; 5 import org.apache.ws.jaxme.generator.util.JavaNamer; 6 import org.apache.ws.jaxme.js.JavaQName; 7 import org.apache.ws.jaxme.js.JavaQNameImpl; 8 import org.xml.sax.SAXException ; 9 10 11 13 public class GroupUtil { 14 16 public static String getGroupName(GroupSG pGroup) throws SAXException { 17 if (pGroup.isGlobal()) { 18 return JavaNamer.convert(pGroup.getName().getLocalName(), pGroup.getSchema()); 19 } else { 20 String sep; 21 StringBuffer sb = new StringBuffer (); 22 if (pGroup.isSequence() || pGroup.isAll()) { 23 sep = "And"; 24 } else { 25 sep = "Choice"; 26 } 27 int num = 0; 28 ParticleSG[] groupParticles = pGroup.getParticles(); 29 for (int i = 0; i < groupParticles.length; i++) { 30 ParticleSG particle = groupParticles[i]; 31 if (particle.isElement()) { 32 if (num++ > 0) { 33 sb.append(sep); 34 } 35 String f = particle.getPropertySG().getPropertyName(); 36 sb.append(Character.toUpperCase(f.charAt(0)) + f.substring(1)); 37 if (num == 3) { 38 break; 39 } 40 } 41 } 42 if (sb.length() == 0) { 43 return "Group"; 44 } else { 45 return sb.toString(); 46 } 47 } 48 } 49 50 static JavaQName getContentClass(GroupSG pGroup, ParticleSG pParticle, 51 JavaQName pQName) throws SAXException { 52 String name = pParticle.getPropertySG().getPropertyName(); 53 name = Character.toUpperCase(name.charAt(0)) + name.substring(1); 54 if (pGroup.isGlobal()) { 55 return JavaQNameImpl.getInstance(pQName.getPackageName(), 56 getGroupName(pGroup) + name); 57 } else { 58 return JavaQNameImpl.getInnerInstance(pQName, name); 59 } 60 } 61 } 62 | Popular Tags |