package org.simantics.xml.sax; import org.w3._2001.xmlschema.Any; import org.w3._2001.xmlschema.Element; import org.w3._2001.xmlschema.Group; public class SchemaElement { public enum ElementType{CHOICE,SEQUENCE,ALL,ANY,ELEMENT,NAMED_GROUP, GROUP_REF} private Group gelement; private Any aelement; private Element eelement; private MultiplicityRestriction restriction; private SchemaElement.ElementType type; private SchemaElement parent; public SchemaElement(Group element, ElementType indicator) { this.gelement = element; this.type = indicator; this.restriction = new MultiplicityRestriction(element); } public SchemaElement(Any element, ElementType indicator) { this.aelement = element; this.type = indicator; this.restriction = new MultiplicityRestriction(element); } public SchemaElement(Element element, ElementType indicator) { this.eelement = element; this.type = indicator; this.restriction = new MultiplicityRestriction(element); } public SchemaElement(SchemaElement parent, Group element, ElementType indicator) { this.parent = parent; this.gelement = element; this.type = indicator; this.restriction = new MultiplicityRestriction(element); } public SchemaElement(SchemaElement parent, Any element, ElementType indicator) { this.parent = parent; this.aelement = element; this.type = indicator; this.restriction = new MultiplicityRestriction(element); } public SchemaElement(SchemaElement parent, Element element, ElementType indicator) { this.parent = parent; this.eelement = element; this.type = indicator; this.restriction = new MultiplicityRestriction(element); } public Group getGroup() { return gelement; } public Any getAny() { return aelement; } public Element getElement() { return eelement; } public MultiplicityRestriction getRestriction() { return restriction; } public ElementType getType() { return type; } public SchemaElement getParent() { return parent; } public boolean order() { if (type == ElementType.ELEMENT) { if (restriction.many()) return true; return false; } if (type == ElementType.SEQUENCE) return true; return false; } public boolean many() { if (restriction.many()) return true; if (parent != null) return parent.many(); return false; } }