1 11 package org.eclipse.pde.internal.core.schema; 12 13 import java.io.PrintWriter ; 14 15 import org.eclipse.pde.core.IWritable; 16 import org.eclipse.pde.internal.core.ischema.ISchema; 17 import org.eclipse.pde.internal.core.ischema.ISchemaRestriction; 18 import org.eclipse.pde.internal.core.ischema.ISchemaSimpleType; 19 20 public class SchemaSimpleType 21 extends SchemaType 22 implements ISchemaSimpleType, IWritable { 23 24 private static final long serialVersionUID = 1L; 25 private ISchemaRestriction restriction; 26 public static final String P_RESTRICTION = "restriction"; 28 public SchemaSimpleType(ISchema schema, String typeName) { 29 super(schema, typeName); 30 } 31 public SchemaSimpleType(ISchemaSimpleType type) { 32 super(type.getSchema(), type.getName()); 33 ISchemaRestriction rest = type.getRestriction(); 34 if (rest != null) { 35 if (rest instanceof ChoiceRestriction) { 36 restriction = new ChoiceRestriction((ChoiceRestriction) rest); 37 restriction.setBaseType(this); 38 } 39 } 40 } 41 public ISchemaRestriction getRestriction() { 42 return restriction; 43 } 44 45 public void setSchema(ISchema schema) { 46 super.setSchema(schema); 47 if (restriction != null) 48 restriction.setParent(schema); 49 } 50 51 public void setRestriction(ISchemaRestriction restriction) { 52 Object oldValue = this.restriction; 53 this.restriction = restriction; 54 if (restriction != null) 55 restriction.setBaseType(this); 56 getSchema().fireModelObjectChanged( 57 this, 58 P_RESTRICTION, 59 oldValue, 60 restriction); 61 } 62 public void write(String indent, PrintWriter writer) { 63 writer.println(indent + "<simpleType>"); if (restriction != null) { 65 restriction.write(indent + Schema.INDENT, writer); 66 } 67 writer.println(indent + "</simpleType>"); } 69 } 70 | Popular Tags |