| 1 |
|
package uk.co.badgersinfoil.asxsd.components; |
| 2 |
|
|
| 3 |
|
import org.eclipse.xsd.XSDConcreteComponent; |
| 4 |
|
import org.eclipse.xsd.XSDModelGroup; |
| 5 |
|
import org.eclipse.xsd.XSDParticle; |
| 6 |
|
import uk.co.badgersinfoil.asxsd.CodegenContext; |
| 7 |
|
import uk.co.badgersinfoil.asxsd.CodegenRole; |
| 8 |
|
|
| 9 |
15 |
public class ModelGroupParticleComponent extends AbstractMappingComponent { |
| 10 |
|
|
| 11 |
|
public boolean willAccept(XSDConcreteComponent component) { |
| 12 |
55 |
if (!(component instanceof XSDParticle)) { |
| 13 |
11 |
return false; |
| 14 |
|
} |
| 15 |
44 |
XSDParticle particle = (XSDParticle)component; |
| 16 |
44 |
return particle.getContent() instanceof XSDModelGroup |
| 17 |
|
&& particle.getMinOccurs() == 1 |
| 18 |
|
&& particle.getMaxOccurs() == 1; |
| 19 |
|
} |
| 20 |
|
|
| 21 |
|
public void generateCode(CodegenContext context, XSDConcreteComponent component) { |
| 22 |
42 |
XSDParticle particle = (XSDParticle)component; |
| 23 |
42 |
CodegenRole role = context.getCurrentRole(); |
| 24 |
42 |
if (role == CodegenRole.UNMARSHAL) { |
| 25 |
14 |
context.generateCode(particle.getContent()); |
| 26 |
28 |
} else if (role == CodegenRole.MARSHAL) { |
| 27 |
14 |
context.generateCode(particle.getContent()); |
| 28 |
14 |
} else if (role == CodegenRole.TYPE) { |
| 29 |
14 |
context.generateCode(particle.getContent()); |
| 30 |
|
} else { |
| 31 |
0 |
super.generateCode(context, component); |
| 32 |
|
} |
| 33 |
42 |
} |
| 34 |
|
|
| 35 |
|
public String createTypeNameFor(CodegenContext context, |
| 36 |
|
XSDConcreteComponent component) |
| 37 |
|
{ |
| 38 |
2 |
return context.createTypeNameFor(component.getContainer()); |
| 39 |
|
} |
| 40 |
|
} |